Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed regression in Widget.getByNode when the bb node id was changed.…

… Fixes #2532619
  • Loading branch information...
commit 8cedb47bec9f0ce7aa3dceb3accb2bee95c1a2f4 1 parent bae036e
@sdesai sdesai authored
Showing with 23 additions and 11 deletions.
  1. +15 −0 src/widget/HISTORY.md
  2. +8 −11 src/widget/js/Widget.js
View
15 src/widget/HISTORY.md
@@ -1,6 +1,21 @@
Widget Change History
=====================
+3.6.1
+-----
+
+ * Fixed regression in `Widget.getByNode()`, introduced in 3.5.0, where the
+ Widget would not be found if the user changed the id of the boundingBox node,
+ after the widget was rendered.
+
+ We go back to using the Node's guid for caching instead of the DOM node id.
+
+ The change was originally made to lay the groundwork for string based rendering,
+ where a boundingBox node reference would not be present during initialization.
+
+ This can still be achieved post-render by populating the instance map, after a
+ Node reference has been established/added to the DOM (when we get there).
+
3.6.0
-----
View
19 src/widget/js/Widget.js
@@ -340,15 +340,13 @@ _getWidgetClassName = Widget.getClassName;
*/
Widget.getByNode = function(node) {
var widget,
- nodeid,
widgetMarker = _getWidgetClassName();
node = Node.one(node);
if (node) {
node = node.ancestor("." + widgetMarker, true);
if (node) {
- nodeid = node.get(ID);
- widget = _instances[nodeid];
+ widget = _instances[Y.stamp(node, true)];
}
}
@@ -391,8 +389,9 @@ Y.extend(Widget, Y.Base, {
Y.log('initializer called', 'life', 'widget');
var bb = this.get(BOUNDING_BOX);
+
if (bb instanceof Node) {
- this._mapInstance(bb.get(ID));
+ this._mapInstance(Y.stamp(bb));
}
/**
@@ -422,9 +421,7 @@ Y.extend(Widget, Y.Base, {
* @protected
*/
_mapInstance : function(id) {
- if (!(_instances[id])) {
- _instances[id] = this;
- }
+ _instances[id] = this;
},
/**
@@ -439,13 +436,13 @@ Y.extend(Widget, Y.Base, {
Y.log('destructor called', 'life', 'widget');
var boundingBox = this.get(BOUNDING_BOX),
- bbid;
+ bbGuid;
if (boundingBox instanceof Node) {
- bbid = boundingBox.get(ID);
+ bbGuid = Y.stamp(boundingBox,true);
- if (bbid in _instances) {
- delete _instances[bbid];
+ if (bbGuid in _instances) {
+ delete _instances[bbGuid];
}
this._destroyBox();
Please sign in to comment.
Something went wrong with that request. Please try again.