Opened 7 years ago

Closed 7 years ago

#18542 closed defect (fixed)

[regression] Relative databinding incorrectly binds to window object

Reported by: neville1355 Owned by:
Priority: undecided Milestone: 1.10.5
Component: General Version: 1.10.4
Keywords: Cc:
Blocked By: Blocking:


Discovered when upgrading from dojo 1.9.4 to 1.10.4

We heavily use databinding and nested groups in order to handle the fluctuating state of our data. In dojo 1.10.4, we observed that in some cases our groups were binding to the window object which would cause exceptions when we happened to use the same property as exists in the window object itself (for example "Comment").

The problem was introduced in lang.getObject:

getObject: function(name, create, context)...
return getProp(name ? name.split(".") : [], create, context); // Object

In our groups which do not necessarily start with a model (loaded via ajax), getObject is called via resolve.js with the following parameters:

lang.getObject("", false, null);

In 1.9.4 this returned undefined, in 1.10.4 this returns the window object.

The result of this call is used to initially databind which causes many issues for us as in some cases we use the same property name as the window object.

Observe the attached test case in which a widget with nested groups using "rel:" binds to the "Comment" property. Since "Comment" exists in the window (at least on chrome), "function" is printed on screen. In 1.9.4 nothing is there.

Attachments (1)

databindingbug.html (1.7 KB) - added by neville1355 7 years ago.

Download all attachments as: .zip

Change History (5)

Changed 7 years ago by neville1355

Attachment: databindingbug.html added

comment:1 Changed 7 years ago by bill

I guess I broke this in #16291. My last checkin's comment says:

In 2957d1b090ae44f2e821e98ea754c99700672d5a/dojo: Make getObject("", false, obj) return obj rather than undefined. Matches 1.9 behavior and fixes many dojox/mvc/tests failures. Refs #16291.

So according to the 1.9 behavior and as a corollary to my comment, lang.getObject("", false, null); should return null, not window.

comment:2 Changed 7 years ago by neville1355

Null or undefined should work, I believe. Was there a reason to return a reference to window instead of null/undefined? If so it may be easier to patch something into resolve.js which is what we have done locally for now.

comment:3 Changed 7 years ago by bill

I don't think there was any reason to return window; it was just a side effect of fixing another bug.

comment:4 Changed 7 years ago by bill

Milestone: tbd1.10.5
Resolution: fixed
Status: newclosed
Summary: Relative databinding incorrectly binds to window object[regression] Relative databinding incorrectly binds to window object

I pushed asudoh's fix in 05e25e2c6880a65fcc674fa5b22e7339085e7376 and backported to 1.10 in 05e25e2c6880a65fcc674fa5b22e7339085e7376.

Note: See TracTickets for help on using tickets.