Opened 6 years ago
Closed 6 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: |
Description
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)
Change History (5)
Changed 6 years ago by
Attachment: | databindingbug.html added |
---|
comment:1 Changed 6 years ago by
comment:2 Changed 6 years ago by
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 6 years ago by
I don't think there was any reason to return window; it was just a side effect of fixing another bug.
comment:4 Changed 6 years ago by
Milestone: | tbd → 1.10.5 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
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.
I guess I broke this in #16291. My last checkin's comment says:
So according to the 1.9 behavior and as a corollary to my comment,
lang.getObject("", false, null);
should return null, not window.