Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Y.Node._instances breaks GC #1637

Open
wants to merge 7 commits into from

2 participants

@jafl

This picks up where the old Ticket #2532270 left off.

Breaking the GC model drags us back to manual memory management. IE6 and IE7 force us to do this anyway, but YUI should not force this upon developers who choose to not target these older browsers.

Another example: If I dereference a Node instance and pass it to a 3rd party widget that operates on raw DOM elements, then even if that widget cleans up correctly, the DOM node won't get cleaned up as long as the Node instance still exists.

By storing the Y.Node reference on the DOM element instead of in Y.Node._instances, then none of this is a problem.

@jafl

The failed build is due to Charts. I think that must also be in dev-master, not related to my changes.

@juandopazo
Collaborator

Sorry for rehasing. If the goal is to only fix this in modern browsers, can we just use a WeakMap and slowly get the new behavior as browsers implement it? It's a lot simpler than keeping a flag everywhere and it's already there in Firefox and IE11.

@jafl

My understanding of WeakMap is that (1) the keys are objects and (2) only the keys are subject to garbage collection. Since the keys in Y.Node._instances are strings, WeakMap doesn't sound applicable.

@juandopazo
Collaborator

But the idea is to map DOM Nodes to YUI Nodes. When using the WeakMap you'd just use the DOM node as the key.

@jafl

Doh. You're right. However, I'm not sure the code will be any simpler, because you'll still have to test whether or not WeakMap is available. And it looks like it may still be a while before it's available in enough browsers to be reliable. If it's only available in some browsers, it's no help, because you still have to keep doing manual memory management. My patch fixes it for everything except IE6 and IE7, which are already basically dead.

@juandopazo
Collaborator

I think your implementation is fine (storing the YUI node in the DOM node), but I still think we should be using a WeakMap as the correct future-proof solution.

@jafl

I agree that WeakMap is the ideal long-term solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
4 build/node-core/node-core-coverage.js
2 additions, 2 deletions not shown
View
84 build/node-core/node-core-debug.js
@@ -30,6 +30,8 @@ var DOT = '.',
UID = '_yuid',
EMPTY_OBJ = {},
+ use_instance_map = 0 < Y.UA.ie && Y.UA.ie < 10, // define flag, in case other browsers need it, too
+
_slice = Array.prototype.slice,
Y_DOM = Y.DOM,
@@ -48,7 +50,7 @@ var DOT = '.',
var uid = (node.nodeType !== 9) ? node.uniqueID : node[UID];
- if (uid && Y_Node._instances[uid] && Y_Node._instances[uid]._node !== node) {
+ if (use_instance_map && uid && Y_Node._instances[uid] && Y_Node._instances[uid]._node !== node) {
node[UID] = null; // unset existing uid to prevent collision (via clone or hack)
}
@@ -125,14 +127,17 @@ Y_Node.SHOW_TRANSITION = 'fadeIn';
Y_Node.HIDE_TRANSITION = 'fadeOut';
/**
- * A list of Node instances that have been created
+ * A list of Node instances that have been created. Only defined in browsers
+ * that already have broken GC, since this global map also breaks GC.
* @private
* @type Object
* @property _instances
* @static
*
*/
-Y_Node._instances = {};
+if (use_instance_map) {
+ Y_Node._instances = {};
+}
/**
* Retrieves the DOM node bound to a Node instance
@@ -289,13 +294,24 @@ Y_Node.one = function(node) {
}
if (node.nodeType || Y.DOM.isWindow(node)) { // avoid bad input (numbers, boolean, etc)
- uid = (node.uniqueID && node.nodeType !== 9) ? node.uniqueID : node._yuid;
- instance = Y_Node._instances[uid]; // reuse exising instances
+ if (use_instance_map) {
+ uid = (node.uniqueID && node.nodeType !== 9) ? node.uniqueID : node[UID];
+ instance = Y_Node._instances[uid]; // reuse exising instances
+ } else {
+ instance = node._yui_instances && node._yui_instances[Y._yuid]; // reuse exising instances
+ }
cachedNode = instance ? instance._node : null;
if (!instance || (cachedNode && node !== cachedNode)) { // new Node when nodes don't match
instance = new Y_Node(node);
- if (node.nodeType != 11) { // dont cache document fragment
- Y_Node._instances[instance[UID]] = instance; // cache node
+ if (node.nodeType != 11) { // don't cache document fragment
+ if (use_instance_map) {
+ Y_Node._instances[instance[UID]] = instance; // cache node
+ } else {
+ if (!node._yui_instances) {
+ node._yui_instances = {};
+ }
+ node._yui_instances[Y._yuid] = instance; // cache node
+ }
}
}
}
@@ -377,7 +393,6 @@ Y.mix(Y_Node.prototype, {
str += '.' + className.replace(' ', '.');
}
- // TODO: add yuid?
str += ' ' + this[UID];
}
return str;
@@ -747,7 +762,11 @@ Y.mix(Y_Node.prototype, {
if (recursive) {
Y.NodeList.each(this.all('*'), function(node) {
- instance = Y_Node._instances[node[UID]];
+ if (use_instance_map) {
+ instance = Y_Node._instances[node[UID]];
+ } else {
+ instance = node._yui_instances && node._yui_instances[Y._yuid];
+ }
if (instance) {
instance.destroy();
} else { // purge in case added by other means
@@ -756,10 +775,16 @@ Y.mix(Y_Node.prototype, {
});
}
+ if (this._node._yui_instances) {
+ delete this._node._yui_instances[Y._yuid];
+ }
+
this._node = null;
this._stateProxy = null;
- delete Y_Node._instances[this._yuid];
+ if (use_instance_map) {
+ delete Y_Node._instances[this[UID]];
+ }
},
/**
@@ -928,11 +953,18 @@ NodeList.addMethod = function(name, fn, context) {
args = arguments;
Y.Array.each(this._nodes, function(node) {
- var UID = (node.uniqueID && node.nodeType !== 9 ) ? 'uniqueID' : '_yuid',
- instance = Y.Node._instances[node[UID]],
+ var uid,
+ instance,
ctx,
result;
+ if (Y.Node._instances) {
+ uid = (node.uniqueID && node.nodeType !== 9 ) ? node.uniqueID : node[UID];
+ instance = Y.Node._instances[uid];
+ } else {
+ instance = node._yui_instances && node._yui_instances[Y._yuid];
+ }
+
if (!instance) {
instance = NodeList._getTempNode(node);
}
@@ -1021,7 +1053,16 @@ Y.mix(NodeList.prototype, {
var nodelist = this;
Y.Array.each(this._nodes, function(node, index) {
- var instance = Y.Node._instances[node[UID]];
+ var uid,
+ instance;
+
+ if (Y.Node._instances) {
+ uid = (node.uniqueID && node.nodeType !== 9 ) ? node.uniqueID : node[UID];
+ instance = Y.Node._instances[uid];
+ } else {
+ instance = node._yui_instances && node._yui_instances[Y._yuid];
+ }
+
if (!instance) {
instance = NodeList._getTempNode(node);
}
@@ -1259,11 +1300,19 @@ NodeList.prototype.get = function(attr) {
nodes = this._nodes,
isNodeList = false,
getTemp = NodeList._getTempNode,
+ uid,
instance,
val;
if (nodes[0]) {
- instance = Y.Node._instances[nodes[0]._yuid] || getTemp(nodes[0]);
+ if (Y.Node._instances) {
+ uid = (nodes[0].uniqueID && nodes[0].nodeType !== 9 ) ? nodes[0].uniqueID : nodes[0][UID];
+ instance = Y.Node._instances[uid];
+ } else {
+ instance = nodes[0]._yui_instances && nodes[0]._yui_instances[Y._yuid];
+ }
+ instance = instance || getTemp(nodes[0]);
+
val = instance._get(attr);
if (val && val.nodeType) {
isNodeList = true;
@@ -1271,7 +1320,12 @@ NodeList.prototype.get = function(attr) {
}
Y.Array.each(nodes, function(node) {
- instance = Y.Node._instances[node._yuid];
+ if (Y.Node._instances) {
+ uid = (node.uniqueID && node.nodeType !== 9 ) ? node.uniqueID : node[UID];
+ instance = Y.Node._instances[uid];
+ } else {
+ instance = node._yui_instances && node._yui_instances[Y._yuid];
+ }
if (!instance) {
instance = getTemp(node);
View
4 build/node-core/node-core-min.js
@@ -1,2 +1,2 @@
-YUI.add("node-core",function(e,t){var n=".",r="nodeName",i="nodeType",s="ownerDocument",o="tagName",u="_yuid",a={},f=Array.prototype.slice,l=e.DOM,c=function(t){if(!this.getDOMNode)return new c(t);if(typeof t=="string"){t=c._fromString(t);if(!t)return null}var n=t.nodeType!==9?t.uniqueID:t[u];n&&c._instances[n]&&c._instances[n]._node!==t&&(t[u]=null),n=n||e.stamp(t),n||(n=e.guid()),this[u]=n,this._node=t,this._stateProxy=t,this._initPlugins&&this._initPlugins()},h=function(t){var n=null;return t&&(n=typeof t=="string"?function(n){return e.Selector.test(n,t)}:function(n){return t(e.one(n))}),n};c.ATTRS={},c.DOM_EVENTS={},c._fromString=function(t){return t&&(t.indexOf("doc")===0?t=e.config.doc:t.indexOf("win")===0?t=e.config.win:t=e.Selector.query(t,null,!0)),t||null},c.NAME="node",c.re_aria=/^(?:role$|aria-)/,c.SHOW_TRANSITION="fadeIn",c.HIDE_TRANSITION="fadeOut",c._instances={},c.getDOMNode=function(e){return e?e.nodeType?e:e._node||null:null},c.scrubVal=function(t,n){if(t){if(typeof t=="object"||typeof t=="function")if(i in t||l.isWindow(t))t=e.one(t);else if(t.item&&!t._nodes||t[0]&&t[0][i])t=e.all(t)}else typeof t=="undefined"?t=n:t===null&&(t=null);return t},c.addMethod=function(e,t,n){e&&t&&typeof t=="function"&&(c.prototype[e]=function(){var e=f.call(arguments),r=this,i;return e[0]&&e[0]._node&&(e[0]=e[0]._node),e[1]&&e[1]._node&&(e[1]=e[1]._node),e.unshift(r._node),i=t.apply(n||r,e),i&&(i=c.scrubVal(i,r)),typeof i!="undefined"||(i=r),i})},c.importMethod=function(t,n,r){typeof n=="string"?(r=r||n,c.addMethod(r,t[n],t)):e.Array.each(n,function(e){c.importMethod(t,e)})},c.one=function(t){var n=null,r,i;if(t){if(typeof t=="string"){t=c._fromString(t);if(!t)return null}else if(t.getDOMNode)return t;if(t.nodeType||e.DOM.isWindow(t)){i=t.uniqueID&&t.nodeType!==9?t.uniqueID:t._yuid,n=c._instances[i],r=n?n._node:null;if(!n||r&&t!==r)n=new c(t),t.nodeType!=11&&(c._instances[n[u]]=n)}}return n},c.DEFAULT_SETTER=function(t,r){var i=this._stateProxy,s;return t.indexOf(n)>-1?(s=t,t=t.split(n),e.Object.setValue(i,t,r)):typeof i[t]!="undefined"&&(i[t]=r),r},c.DEFAULT_GETTER=function(t){var r=this._stateProxy,i;return t.indexOf&&t.indexOf(n)>-1?i=e.Object.getValue(r,t.split(n)):typeof r[t]!="undefined"&&(i=r[t]),i},e.mix(c.prototype,{DATA_PREFIX:"data-",toString:function(){var e=this[u]+": not bound to a node",t=this._node,n,i,s;return t&&(n=t.attributes,i=n&&n.id?t.getAttribute("id"):null,s=n&&n.className?t.getAttribute("className"):null,e=t[r],i&&(e+="#"+i),s&&(e+="."+s.replace(" ",".")),e+=" "+this[u]),e},get:function(e){var t;return this._getAttr?t=this._getAttr(e):t=this._get(e),t?t=c.scrubVal(t,this):t===null&&(t=null),t},_get:function(e){var t=c.ATTRS[e],n;return t&&t.getter?n=t.getter.call(this):c.re_aria.test(e)?n=this._node.getAttribute(e,2):n=c.DEFAULT_GETTER.apply(this,arguments),n},set:function(e,t){var n=c.ATTRS[e];return this._setAttr?this._setAttr.apply(this,arguments):n&&n.setter?n.setter.call(this,t,e):c.re_aria.test(e)?this._node.setAttribute(e,t):c.DEFAULT_SETTER.apply(this,arguments),this},setAttrs:function(t){return this._setAttrs?this._setAttrs(t):e.Object.each(t,function(e,t){this.set(t,e)},this),this},getAttrs:function(t){var n={};return this._getAttrs?this._getAttrs(t):e.Array.each(t,function(e,t){n[e]=this.get(e)},this),n},compareTo:function(e){var t=this._node;return e&&e._node&&(e=e._node),t===e},inDoc:function(e){var t=this._node;if(t){e=e?e._node||e:t[s];if(e.documentElement)return l.contains(e.documentElement,t)}return!1},getById:function(t){var n=this._node,r=l.byId(t,n[s]);return r&&l.contains(n,r)?r=e.one(r):r=null,r},ancestor:function(t,n,r){return arguments.length===2&&(typeof n=="string"||typeof n=="function")&&(r=n),e.one(l.ancestor(this._node,h(t),n,h(r)))},ancestors:function(t,n,r){return arguments.length===2&&(typeof n=="string"||typeof n=="function")&&(r=n),e.all(l.ancestors(this._node,h(t),n,h(r)))},previous:function(t,n){return e.one(l.elementByAxis(this._node,"previousSibling",h(t),n))},next:function(t,n){return e.one(l.elementByAxis(this._node,"nextSibling",h(t),n))},siblings:function(t){return e.all(l.siblings(this._node,h(t)))},one:function(t){return e.one(e.Selector.query(t,this._node,!0))},all:function(t){var n;return this._node&&(n=e.all(e.Selector.query(t,this._node)),n._query=t,n._queryRoot=this._node),n||e.all([])},test:function(t){return e.Selector.test(this._node,t)},remove:function(e){var t=this._node;return t&&t.parentNode&&t.parentNode.removeChild(t),e&&this.destroy(),this},replace:function(e){var t=this._node;return typeof e=="string"&&(e=c.create(e)),t.parentNode.replaceChild(c.getDOMNode(e),t),this},replaceChild:function(t,n){return typeof t=="string"&&(t=l.create(t)),e.one(this._node.replaceChild(c.getDOMNode(t),c.getDOMNode(n)))},destroy:function(t){var n=e.config.doc.uniqueID?"uniqueID":"_yuid",r;this.purge(),this.unplug&&this.unplug(),this.clearData(),t&&e.NodeList.each(this.all("*"),function(t){r=c._instances[t[n]],r?r.destroy():e.Event.purgeElement(t)}),this._node=null,this._stateProxy=null,delete c._instances[this._yuid]},invoke:function(e,t,n,r,i,s){var o=this._node,u;return t&&t._node&&(t=t._node),n&&n._node&&(n=n._node),u=o[e](t,n,r,i,s),c.scrubVal(u,this)},swap:e.config.doc.documentElement.swapNode?function(e){this._node.swapNode(c.getDOMNode(e))}:function(e){e=c.getDOMNode(e);var t=this._node,n=e.parentNode,r=e.nextSibling;return r===t?n.insertBefore(t,e):e===t.nextSibling?n.insertBefore(e,t):(t.parentNode.replaceChild(e,t),l.addHTML(n,t,r)),this},hasMethod:function(e){var t=this._node;return!(!(t&&e in t&&typeof t[e]!="unknown")||typeof t[e]!="function"&&String(t[e]).indexOf("function")!==1)},isFragment:function(){return this.get("nodeType")===11},empty:function(){return this.get("childNodes").remove().destroy(!0),this},getDOMNode:function(){return this._node}},!0),e.Node=c,e.one=c.one;var p=function(t){var n=[];t&&(typeof t=="string"?(this._query=t,t=e.Selector.query(t)):t.nodeType||l.isWindow(t)?t=[t]:t._node?t=[t._node]:
-t[0]&&t[0]._node?(e.Array.each(t,function(e){e._node&&n.push(e._node)}),t=n):t=e.Array(t,0,!0)),this._nodes=t||[]};p.NAME="NodeList",p.getDOMNodes=function(e){return e&&e._nodes?e._nodes:e},p.each=function(t,n,r){var i=t._nodes;i&&i.length&&e.Array.each(i,n,r||t)},p.addMethod=function(t,n,r){t&&n&&(p.prototype[t]=function(){var t=[],i=arguments;return e.Array.each(this._nodes,function(s){var o=s.uniqueID&&s.nodeType!==9?"uniqueID":"_yuid",u=e.Node._instances[s[o]],a,f;u||(u=p._getTempNode(s)),a=r||u,f=n.apply(a,i),f!==undefined&&f!==u&&(t[t.length]=f)}),t.length?t:this})},p.importMethod=function(t,n,r){typeof n=="string"?(r=r||n,p.addMethod(n,t[n])):e.Array.each(n,function(e){p.importMethod(t,e)})},p._getTempNode=function(t){var n=p._tempNode;return n||(n=e.Node.create("<div></div>"),p._tempNode=n),n._node=t,n._stateProxy=t,n},e.mix(p.prototype,{_invoke:function(e,t,n){var r=n?[]:this;return this.each(function(i){var s=i[e].apply(i,t);n&&r.push(s)}),r},item:function(t){return e.one((this._nodes||[])[t])},each:function(t,n){var r=this;return e.Array.each(this._nodes,function(i,s){return i=e.one(i),t.call(n||i,i,s,r)}),r},batch:function(t,n){var r=this;return e.Array.each(this._nodes,function(i,s){var o=e.Node._instances[i[u]];return o||(o=p._getTempNode(i)),t.call(n||o,o,s,r)}),r},some:function(t,n){var r=this;return e.Array.some(this._nodes,function(i,s){return i=e.one(i),n=n||i,t.call(n,i,s,r)})},toFrag:function(){return e.one(e.DOM._nl2frag(this._nodes))},indexOf:function(t){return e.Array.indexOf(this._nodes,e.Node.getDOMNode(t))},filter:function(t){return e.all(e.Selector.filter(this._nodes,t))},modulus:function(t,n){n=n||0;var r=[];return p.each(this,function(e,i){i%t===n&&r.push(e)}),e.all(r)},odd:function(){return this.modulus(2,1)},even:function(){return this.modulus(2)},destructor:function(){},refresh:function(){var t,n=this._nodes,r=this._query,i=this._queryRoot;return r&&(i||n&&n[0]&&n[0].ownerDocument&&(i=n[0].ownerDocument),this._nodes=e.Selector.query(r,i)),this},size:function(){return this._nodes.length},isEmpty:function(){return this._nodes.length<1},toString:function(){var e="",t=this[u]+": not bound to any nodes",n=this._nodes,i;return n&&n[0]&&(i=n[0],e+=i[r],i.id&&(e+="#"+i.id),i.className&&(e+="."+i.className.replace(" ",".")),n.length>1&&(e+="...["+n.length+" items]")),e||t},getDOMNodes:function(){return this._nodes}},!0),p.importMethod(e.Node.prototype,["destroy","empty","remove","set"]),p.prototype.get=function(t){var n=[],r=this._nodes,i=!1,s=p._getTempNode,o,u;return r[0]&&(o=e.Node._instances[r[0]._yuid]||s(r[0]),u=o._get(t),u&&u.nodeType&&(i=!0)),e.Array.each(r,function(r){o=e.Node._instances[r._yuid],o||(o=s(r)),u=o._get(t),i||(u=e.Node.scrubVal(u,o)),n.push(u)}),i?e.all(n):n},e.NodeList=p,e.all=function(e){return new p(e)},e.Node.all=e.all;var d=e.NodeList,v=Array.prototype,m={concat:1,pop:0,push:0,shift:0,slice:1,splice:1,unshift:0};e.Object.each(m,function(t,n){d.prototype[n]=function(){var r=[],i=0,s,o;while(typeof (s=arguments[i++])!="undefined")r.push(s._node||s._nodes||s);return o=v[n].apply(this._nodes,r),t?o=e.all(o):o=e.Node.scrubVal(o),o}}),e.Array.each(["removeChild","hasChildNodes","cloneNode","hasAttribute","scrollIntoView","getElementsByTagName","focus","blur","submit","reset","select","createCaption"],function(t){e.Node.prototype[t]=function(e,n,r){var i=this.invoke(t,e,n,r);return i}}),e.Node.prototype.removeAttribute=function(e){var t=this._node;return t&&t.removeAttribute(e,0),this},e.Node.importMethod(e.DOM,["contains","setAttribute","getAttribute","wrap","unwrap","generateID"]),e.NodeList.importMethod(e.Node.prototype,["getAttribute","setAttribute","removeAttribute","unwrap","wrap","generateID"])},"@VERSION@",{requires:["dom-core","selector"]});
+YUI.add("node-core",function(e,t){var n=".",r="nodeName",i="nodeType",s="ownerDocument",o="tagName",u="_yuid",a={},f=0<e.UA.ie&&e.UA.ie<10,l=Array.prototype.slice,c=e.DOM,h=function(t){if(!this.getDOMNode)return new h(t);if(typeof t=="string"){t=h._fromString(t);if(!t)return null}var n=t.nodeType!==9?t.uniqueID:t[u];f&&n&&h._instances[n]&&h._instances[n]._node!==t&&(t[u]=null),n=n||e.stamp(t),n||(n=e.guid()),this[u]=n,this._node=t,this._stateProxy=t,this._initPlugins&&this._initPlugins()},p=function(t){var n=null;return t&&(n=typeof t=="string"?function(n){return e.Selector.test(n,t)}:function(n){return t(e.one(n))}),n};h.ATTRS={},h.DOM_EVENTS={},h._fromString=function(t){return t&&(t.indexOf("doc")===0?t=e.config.doc:t.indexOf("win")===0?t=e.config.win:t=e.Selector.query(t,null,!0)),t||null},h.NAME="node",h.re_aria=/^(?:role$|aria-)/,h.SHOW_TRANSITION="fadeIn",h.HIDE_TRANSITION="fadeOut",f&&(h._instances={}),h.getDOMNode=function(e){return e?e.nodeType?e:e._node||null:null},h.scrubVal=function(t,n){if(t){if(typeof t=="object"||typeof t=="function")if(i in t||c.isWindow(t))t=e.one(t);else if(t.item&&!t._nodes||t[0]&&t[0][i])t=e.all(t)}else typeof t=="undefined"?t=n:t===null&&(t=null);return t},h.addMethod=function(e,t,n){e&&t&&typeof t=="function"&&(h.prototype[e]=function(){var e=l.call(arguments),r=this,i;return e[0]&&e[0]._node&&(e[0]=e[0]._node),e[1]&&e[1]._node&&(e[1]=e[1]._node),e.unshift(r._node),i=t.apply(n||r,e),i&&(i=h.scrubVal(i,r)),typeof i!="undefined"||(i=r),i})},h.importMethod=function(t,n,r){typeof n=="string"?(r=r||n,h.addMethod(r,t[n],t)):e.Array.each(n,function(e){h.importMethod(t,e)})},h.one=function(t){var n=null,r,i;if(t){if(typeof t=="string"){t=h._fromString(t);if(!t)return null}else if(t.getDOMNode)return t;if(t.nodeType||e.DOM.isWindow(t)){f?(i=t.uniqueID&&t.nodeType!==9?t.uniqueID:t[u],n=h._instances[i]):n=t._yui_instances&&t._yui_instances[e._yuid],r=n?n._node:null;if(!n||r&&t!==r)n=new h(t),t.nodeType!=11&&(f?h._instances[n[u]]=n:(t._yui_instances||(t._yui_instances={}),t._yui_instances[e._yuid]=n))}}return n},h.DEFAULT_SETTER=function(t,r){var i=this._stateProxy,s;return t.indexOf(n)>-1?(s=t,t=t.split(n),e.Object.setValue(i,t,r)):typeof i[t]!="undefined"&&(i[t]=r),r},h.DEFAULT_GETTER=function(t){var r=this._stateProxy,i;return t.indexOf&&t.indexOf(n)>-1?i=e.Object.getValue(r,t.split(n)):typeof r[t]!="undefined"&&(i=r[t]),i},e.mix(h.prototype,{DATA_PREFIX:"data-",toString:function(){var e=this[u]+": not bound to a node",t=this._node,n,i,s;return t&&(n=t.attributes,i=n&&n.id?t.getAttribute("id"):null,s=n&&n.className?t.getAttribute("className"):null,e=t[r],i&&(e+="#"+i),s&&(e+="."+s.replace(" ",".")),e+=" "+this[u]),e},get:function(e){var t;return this._getAttr?t=this._getAttr(e):t=this._get(e),t?t=h.scrubVal(t,this):t===null&&(t=null),t},_get:function(e){var t=h.ATTRS[e],n;return t&&t.getter?n=t.getter.call(this):h.re_aria.test(e)?n=this._node.getAttribute(e,2):n=h.DEFAULT_GETTER.apply(this,arguments),n},set:function(e,t){var n=h.ATTRS[e];return this._setAttr?this._setAttr.apply(this,arguments):n&&n.setter?n.setter.call(this,t,e):h.re_aria.test(e)?this._node.setAttribute(e,t):h.DEFAULT_SETTER.apply(this,arguments),this},setAttrs:function(t){return this._setAttrs?this._setAttrs(t):e.Object.each(t,function(e,t){this.set(t,e)},this),this},getAttrs:function(t){var n={};return this._getAttrs?this._getAttrs(t):e.Array.each(t,function(e,t){n[e]=this.get(e)},this),n},compareTo:function(e){var t=this._node;return e&&e._node&&(e=e._node),t===e},inDoc:function(e){var t=this._node;if(t){e=e?e._node||e:t[s];if(e.documentElement)return c.contains(e.documentElement,t)}return!1},getById:function(t){var n=this._node,r=c.byId(t,n[s]);return r&&c.contains(n,r)?r=e.one(r):r=null,r},ancestor:function(t,n,r){return arguments.length===2&&(typeof n=="string"||typeof n=="function")&&(r=n),e.one(c.ancestor(this._node,p(t),n,p(r)))},ancestors:function(t,n,r){return arguments.length===2&&(typeof n=="string"||typeof n=="function")&&(r=n),e.all(c.ancestors(this._node,p(t),n,p(r)))},previous:function(t,n){return e.one(c.elementByAxis(this._node,"previousSibling",p(t),n))},next:function(t,n){return e.one(c.elementByAxis(this._node,"nextSibling",p(t),n))},siblings:function(t){return e.all(c.siblings(this._node,p(t)))},one:function(t){return e.one(e.Selector.query(t,this._node,!0))},all:function(t){var n;return this._node&&(n=e.all(e.Selector.query(t,this._node)),n._query=t,n._queryRoot=this._node),n||e.all([])},test:function(t){return e.Selector.test(this._node,t)},remove:function(e){var t=this._node;return t&&t.parentNode&&t.parentNode.removeChild(t),e&&this.destroy(),this},replace:function(e){var t=this._node;return typeof e=="string"&&(e=h.create(e)),t.parentNode.replaceChild(h.getDOMNode(e),t),this},replaceChild:function(t,n){return typeof t=="string"&&(t=c.create(t)),e.one(this._node.replaceChild(h.getDOMNode(t),h.getDOMNode(n)))},destroy:function(t){var n=e.config.doc.uniqueID?"uniqueID":"_yuid",r;this.purge(),this.unplug&&this.unplug(),this.clearData(),t&&e.NodeList.each(this.all("*"),function(t){f?r=h._instances[t[n]]:r=t._yui_instances&&t._yui_instances[e._yuid],r?r.destroy():e.Event.purgeElement(t)}),this._node._yui_instances&&delete this._node._yui_instances[e._yuid],this._node=null,this._stateProxy=null,f&&delete h._instances[this[n]]},invoke:function(e,t,n,r,i,s){var o=this._node,u;return t&&t._node&&(t=t._node),n&&n._node&&(n=n._node),u=o[e](t,n,r,i,s),h.scrubVal(u,this)},swap:e.config.doc.documentElement.swapNode?function(e){this._node.swapNode(h.getDOMNode(e))}:function(e){e=h.getDOMNode(e);var t=this._node,n=e.parentNode,r=e.nextSibling;return r===t?n.insertBefore(t,e):e===t.nextSibling?n.insertBefore(e,t):(t.parentNode.replaceChild(e,t),c.addHTML(n,t,r)),this},hasMethod:function(e){var t=this._node;return!(!(t&&e in t&&typeof t[e]!="unknown")||typeof t[e]!="function"&&String(t[e]).indexOf("function")!==1)},isFragment:function(){return this.get("nodeType")===11},empty:function(
+){return this.get("childNodes").remove().destroy(!0),this},getDOMNode:function(){return this._node}},!0),e.Node=h,e.one=h.one;var d=function(t){var n=[];t&&(typeof t=="string"?(this._query=t,t=e.Selector.query(t)):t.nodeType||c.isWindow(t)?t=[t]:t._node?t=[t._node]:t[0]&&t[0]._node?(e.Array.each(t,function(e){e._node&&n.push(e._node)}),t=n):t=e.Array(t,0,!0)),this._nodes=t||[]};d.NAME="NodeList",d.getDOMNodes=function(e){return e&&e._nodes?e._nodes:e},d.each=function(t,n,r){var i=t._nodes;i&&i.length&&e.Array.each(i,n,r||t)},d.addMethod=function(t,n,r){t&&n&&(d.prototype[t]=function(){var t=[],i=arguments;return e.Array.each(this._nodes,function(s){var o,a,f,l;e.Node._instances?(o=s.uniqueID&&s.nodeType!==9?s.uniqueID:s[u],a=e.Node._instances[o]):a=s._yui_instances&&s._yui_instances[e._yuid],a||(a=d._getTempNode(s)),f=r||a,l=n.apply(f,i),l!==undefined&&l!==a&&(t[t.length]=l)}),t.length?t:this})},d.importMethod=function(t,n,r){typeof n=="string"?(r=r||n,d.addMethod(n,t[n])):e.Array.each(n,function(e){d.importMethod(t,e)})},d._getTempNode=function(t){var n=d._tempNode;return n||(n=e.Node.create("<div></div>"),d._tempNode=n),n._node=t,n._stateProxy=t,n},e.mix(d.prototype,{_invoke:function(e,t,n){var r=n?[]:this;return this.each(function(i){var s=i[e].apply(i,t);n&&r.push(s)}),r},item:function(t){return e.one((this._nodes||[])[t])},each:function(t,n){var r=this;return e.Array.each(this._nodes,function(i,s){return i=e.one(i),t.call(n||i,i,s,r)}),r},batch:function(t,n){var r=this;return e.Array.each(this._nodes,function(i,s){var o,a;return e.Node._instances?(o=i.uniqueID&&i.nodeType!==9?i.uniqueID:i[u],a=e.Node._instances[o]):a=i._yui_instances&&i._yui_instances[e._yuid],a||(a=d._getTempNode(i)),t.call(n||a,a,s,r)}),r},some:function(t,n){var r=this;return e.Array.some(this._nodes,function(i,s){return i=e.one(i),n=n||i,t.call(n,i,s,r)})},toFrag:function(){return e.one(e.DOM._nl2frag(this._nodes))},indexOf:function(t){return e.Array.indexOf(this._nodes,e.Node.getDOMNode(t))},filter:function(t){return e.all(e.Selector.filter(this._nodes,t))},modulus:function(t,n){n=n||0;var r=[];return d.each(this,function(e,i){i%t===n&&r.push(e)}),e.all(r)},odd:function(){return this.modulus(2,1)},even:function(){return this.modulus(2)},destructor:function(){},refresh:function(){var t,n=this._nodes,r=this._query,i=this._queryRoot;return r&&(i||n&&n[0]&&n[0].ownerDocument&&(i=n[0].ownerDocument),this._nodes=e.Selector.query(r,i)),this},size:function(){return this._nodes.length},isEmpty:function(){return this._nodes.length<1},toString:function(){var e="",t=this[u]+": not bound to any nodes",n=this._nodes,i;return n&&n[0]&&(i=n[0],e+=i[r],i.id&&(e+="#"+i.id),i.className&&(e+="."+i.className.replace(" ",".")),n.length>1&&(e+="...["+n.length+" items]")),e||t},getDOMNodes:function(){return this._nodes}},!0),d.importMethod(e.Node.prototype,["destroy","empty","remove","set"]),d.prototype.get=function(t){var n=[],r=this._nodes,i=!1,s=d._getTempNode,o,a,f;return r[0]&&(e.Node._instances?(o=r[0].uniqueID&&r[0].nodeType!==9?r[0].uniqueID:r[0][u],a=e.Node._instances[o]):a=r[0]._yui_instances&&r[0]._yui_instances[e._yuid],a=a||s(r[0]),f=a._get(t),f&&f.nodeType&&(i=!0)),e.Array.each(r,function(r){e.Node._instances?(o=r.uniqueID&&r.nodeType!==9?r.uniqueID:r[u],a=e.Node._instances[o]):a=r._yui_instances&&r._yui_instances[e._yuid],a||(a=s(r)),f=a._get(t),i||(f=e.Node.scrubVal(f,a)),n.push(f)}),i?e.all(n):n},e.NodeList=d,e.all=function(e){return new d(e)},e.Node.all=e.all;var v=e.NodeList,m=Array.prototype,g={concat:1,pop:0,push:0,shift:0,slice:1,splice:1,unshift:0};e.Object.each(g,function(t,n){v.prototype[n]=function(){var r=[],i=0,s,o;while(typeof (s=arguments[i++])!="undefined")r.push(s._node||s._nodes||s);return o=m[n].apply(this._nodes,r),t?o=e.all(o):o=e.Node.scrubVal(o),o}}),e.Array.each(["removeChild","hasChildNodes","cloneNode","hasAttribute","scrollIntoView","getElementsByTagName","focus","blur","submit","reset","select","createCaption"],function(t){e.Node.prototype[t]=function(e,n,r){var i=this.invoke(t,e,n,r);return i}}),e.Node.prototype.removeAttribute=function(e){var t=this._node;return t&&t.removeAttribute(e,0),this},e.Node.importMethod(e.DOM,["contains","setAttribute","getAttribute","wrap","unwrap","generateID"]),e.NodeList.importMethod(e.Node.prototype,["getAttribute","setAttribute","removeAttribute","unwrap","wrap","generateID"])},"@VERSION@",{requires:["dom-core","selector"]});
View
84 build/node-core/node-core.js
@@ -30,6 +30,8 @@ var DOT = '.',
UID = '_yuid',
EMPTY_OBJ = {},
+ use_instance_map = 0 < Y.UA.ie && Y.UA.ie < 10, // define flag, in case other browsers need it, too
+
_slice = Array.prototype.slice,
Y_DOM = Y.DOM,
@@ -48,7 +50,7 @@ var DOT = '.',
var uid = (node.nodeType !== 9) ? node.uniqueID : node[UID];
- if (uid && Y_Node._instances[uid] && Y_Node._instances[uid]._node !== node) {
+ if (use_instance_map && uid && Y_Node._instances[uid] && Y_Node._instances[uid]._node !== node) {
node[UID] = null; // unset existing uid to prevent collision (via clone or hack)
}
@@ -125,14 +127,17 @@ Y_Node.SHOW_TRANSITION = 'fadeIn';
Y_Node.HIDE_TRANSITION = 'fadeOut';
/**
- * A list of Node instances that have been created
+ * A list of Node instances that have been created. Only defined in browsers
+ * that already have broken GC, since this global map also breaks GC.
* @private
* @type Object
* @property _instances
* @static
*
*/
-Y_Node._instances = {};
+if (use_instance_map) {
+ Y_Node._instances = {};
+}
/**
* Retrieves the DOM node bound to a Node instance
@@ -288,13 +293,24 @@ Y_Node.one = function(node) {
}
if (node.nodeType || Y.DOM.isWindow(node)) { // avoid bad input (numbers, boolean, etc)
- uid = (node.uniqueID && node.nodeType !== 9) ? node.uniqueID : node._yuid;
- instance = Y_Node._instances[uid]; // reuse exising instances
+ if (use_instance_map) {
+ uid = (node.uniqueID && node.nodeType !== 9) ? node.uniqueID : node[UID];
+ instance = Y_Node._instances[uid]; // reuse exising instances
+ } else {
+ instance = node._yui_instances && node._yui_instances[Y._yuid]; // reuse exising instances
+ }
cachedNode = instance ? instance._node : null;
if (!instance || (cachedNode && node !== cachedNode)) { // new Node when nodes don't match
instance = new Y_Node(node);
- if (node.nodeType != 11) { // dont cache document fragment
- Y_Node._instances[instance[UID]] = instance; // cache node
+ if (node.nodeType != 11) { // don't cache document fragment
+ if (use_instance_map) {
+ Y_Node._instances[instance[UID]] = instance; // cache node
+ } else {
+ if (!node._yui_instances) {
+ node._yui_instances = {};
+ }
+ node._yui_instances[Y._yuid] = instance; // cache node
+ }
}
}
}
@@ -376,7 +392,6 @@ Y.mix(Y_Node.prototype, {
str += '.' + className.replace(' ', '.');
}
- // TODO: add yuid?
str += ' ' + this[UID];
}
return str;
@@ -746,7 +761,11 @@ Y.mix(Y_Node.prototype, {
if (recursive) {
Y.NodeList.each(this.all('*'), function(node) {
- instance = Y_Node._instances[node[UID]];
+ if (use_instance_map) {
+ instance = Y_Node._instances[node[UID]];
+ } else {
+ instance = node._yui_instances && node._yui_instances[Y._yuid];
+ }
if (instance) {
instance.destroy();
} else { // purge in case added by other means
@@ -755,10 +774,16 @@ Y.mix(Y_Node.prototype, {
});
}
+ if (this._node._yui_instances) {
+ delete this._node._yui_instances[Y._yuid];
+ }
+
this._node = null;
this._stateProxy = null;
- delete Y_Node._instances[this._yuid];
+ if (use_instance_map) {
+ delete Y_Node._instances[this[UID]];
+ }
},
/**
@@ -926,11 +951,18 @@ NodeList.addMethod = function(name, fn, context) {
args = arguments;
Y.Array.each(this._nodes, function(node) {
- var UID = (node.uniqueID && node.nodeType !== 9 ) ? 'uniqueID' : '_yuid',
- instance = Y.Node._instances[node[UID]],
+ var uid,
+ instance,
ctx,
result;
+ if (Y.Node._instances) {
+ uid = (node.uniqueID && node.nodeType !== 9 ) ? node.uniqueID : node[UID];
+ instance = Y.Node._instances[uid];
+ } else {
+ instance = node._yui_instances && node._yui_instances[Y._yuid];
+ }
+
if (!instance) {
instance = NodeList._getTempNode(node);
}
@@ -1018,7 +1050,16 @@ Y.mix(NodeList.prototype, {
var nodelist = this;
Y.Array.each(this._nodes, function(node, index) {
- var instance = Y.Node._instances[node[UID]];
+ var uid,
+ instance;
+
+ if (Y.Node._instances) {
+ uid = (node.uniqueID && node.nodeType !== 9 ) ? node.uniqueID : node[UID];
+ instance = Y.Node._instances[uid];
+ } else {
+ instance = node._yui_instances && node._yui_instances[Y._yuid];
+ }
+
if (!instance) {
instance = NodeList._getTempNode(node);
}
@@ -1256,11 +1297,19 @@ NodeList.prototype.get = function(attr) {
nodes = this._nodes,
isNodeList = false,
getTemp = NodeList._getTempNode,
+ uid,
instance,
val;
if (nodes[0]) {
- instance = Y.Node._instances[nodes[0]._yuid] || getTemp(nodes[0]);
+ if (Y.Node._instances) {
+ uid = (nodes[0].uniqueID && nodes[0].nodeType !== 9 ) ? nodes[0].uniqueID : nodes[0][UID];
+ instance = Y.Node._instances[uid];
+ } else {
+ instance = nodes[0]._yui_instances && nodes[0]._yui_instances[Y._yuid];
+ }
+ instance = instance || getTemp(nodes[0]);
+
val = instance._get(attr);
if (val && val.nodeType) {
isNodeList = true;
@@ -1268,7 +1317,12 @@ NodeList.prototype.get = function(attr) {
}
Y.Array.each(nodes, function(node) {
- instance = Y.Node._instances[node._yuid];
+ if (Y.Node._instances) {
+ uid = (node.uniqueID && node.nodeType !== 9 ) ? node.uniqueID : node[UID];
+ instance = Y.Node._instances[uid];
+ } else {
+ instance = node._yui_instances && node._yui_instances[Y._yuid];
+ }
if (!instance) {
instance = getTemp(node);
View
4 build/node-pluginhost/node-pluginhost-coverage.js
@@ -1,6 +1,6 @@
if (typeof __coverage__ === 'undefined') { __coverage__ = {}; }
if (!__coverage__['build/node-pluginhost/node-pluginhost.js']) {
- __coverage__['build/node-pluginhost/node-pluginhost.js'] = {"path":"build/node-pluginhost/node-pluginhost.js","s":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0},"b":{},"f":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0},"fnMap":{"1":{"name":"(anonymous_1)","line":1,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":46}}},"2":{"name":"(anonymous_2)","line":18,"loc":{"start":{"line":18,"column":14},"end":{"line":18,"column":25}}},"3":{"name":"(anonymous_3)","line":33,"loc":{"start":{"line":33,"column":16},"end":{"line":33,"column":27}}},"4":{"name":"(anonymous_4)","line":43,"loc":{"start":{"line":43,"column":33},"end":{"line":43,"column":49}}},"5":{"name":"(anonymous_5)","line":65,"loc":{"start":{"line":65,"column":28},"end":{"line":65,"column":39}}},"6":{"name":"(anonymous_6)","line":67,"loc":{"start":{"line":67,"column":26},"end":{"line":67,"column":41}}},"7":{"name":"(anonymous_7)","line":82,"loc":{"start":{"line":82,"column":30},"end":{"line":82,"column":41}}},"8":{"name":"(anonymous_8)","line":84,"loc":{"start":{"line":84,"column":26},"end":{"line":84,"column":41}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":91,"column":59}},"2":{"start":{"line":18,"column":0},"end":{"line":23,"column":2}},"3":{"start":{"line":19,"column":4},"end":{"line":19,"column":34}},"4":{"start":{"line":20,"column":4},"end":{"line":20,"column":25}},"5":{"start":{"line":21,"column":4},"end":{"line":21,"column":43}},"6":{"start":{"line":22,"column":4},"end":{"line":22,"column":18}},"7":{"start":{"line":33,"column":0},"end":{"line":38,"column":2}},"8":{"start":{"line":34,"column":4},"end":{"line":34,"column":34}},"9":{"start":{"line":35,"column":4},"end":{"line":35,"column":25}},"10":{"start":{"line":36,"column":4},"end":{"line":36,"column":45}},"11":{"start":{"line":37,"column":4},"end":{"line":37,"column":18}},"12":{"start":{"line":40,"column":0},"end":{"line":40,"column":45}},"13":{"start":{"line":43,"column":0},"end":{"line":45,"column":3}},"14":{"start":{"line":44,"column":4},"end":{"line":44,"column":30}},"15":{"start":{"line":65,"column":0},"end":{"line":71,"column":2}},"16":{"start":{"line":66,"column":4},"end":{"line":66,"column":25}},"17":{"start":{"line":67,"column":4},"end":{"line":69,"column":7}},"18":{"start":{"line":68,"column":8},"end":{"line":68,"column":55}},"19":{"start":{"line":70,"column":4},"end":{"line":70,"column":16}},"20":{"start":{"line":82,"column":0},"end":{"line":88,"column":2}},"21":{"start":{"line":83,"column":4},"end":{"line":83,"column":25}},"22":{"start":{"line":84,"column":4},"end":{"line":86,"column":7}},"23":{"start":{"line":85,"column":8},"end":{"line":85,"column":57}},"24":{"start":{"line":87,"column":4},"end":{"line":87,"column":16}}},"branchMap":{},"code":["(function () { YUI.add('node-pluginhost', function (Y, NAME) {","","/**"," * @module node"," * @submodule node-pluginhost"," */","","/**"," * Registers plugins to be instantiated at the class level (plugins"," * which should be plugged into every instance of Node by default)."," *"," * @method plug"," * @static"," * @for Node"," * @param {Function | Array} plugin Either the plugin class, an array of plugin classes or an array of objects (with fn and cfg properties defined)"," * @param {Object} config (Optional) If plugin is the plugin class, the configuration for the plugin"," */","Y.Node.plug = function() {"," var args = Y.Array(arguments);"," args.unshift(Y.Node);"," Y.Plugin.Host.plug.apply(Y.Base, args);"," return Y.Node;","};","","/**"," * Unregisters any class level plugins which have been registered by the Node"," *"," * @method unplug"," * @static"," *"," * @param {Function | Array} plugin The plugin class, or an array of plugin classes"," */","Y.Node.unplug = function() {"," var args = Y.Array(arguments);"," args.unshift(Y.Node);"," Y.Plugin.Host.unplug.apply(Y.Base, args);"," return Y.Node;","};","","Y.mix(Y.Node, Y.Plugin.Host, false, null, 1);","","// run PluginHost constructor on cached Node instances","Y.Object.each(Y.Node._instances, function (node) {"," Y.Plugin.Host.apply(node);","});","","// allow batching of plug/unplug via NodeList","// doesn't use NodeList.importMethod because we need real Nodes (not tmpNode)","/**"," * Adds a plugin to each node in the NodeList."," * This will instantiate the plugin and attach it to the configured namespace on each node"," * @method plug"," * @for NodeList"," * @param P {Function | Object |Array} Accepts the plugin class, or an"," * object with a \"fn\" property specifying the plugin class and"," * a \"cfg\" property specifying the configuration for the Plugin."," * <p>"," * Additionally an Array can also be passed in, with the above function or"," * object values, allowing the user to add multiple plugins in a single call."," * </p>"," * @param config (Optional) If the first argument is the plugin class, the second argument"," * can be the configuration for the plugin."," * @chainable"," */","Y.NodeList.prototype.plug = function() {"," var args = arguments;"," Y.NodeList.each(this, function(node) {"," Y.Node.prototype.plug.apply(Y.one(node), args);"," });"," return this;","};","","/**"," * Removes a plugin from all nodes in the NodeList. This will destroy the"," * plugin instance and delete the namespace each node."," * @method unplug"," * @for NodeList"," * @param {String | Function} plugin The namespace of the plugin, or the plugin class with the static NS namespace property defined. If not provided,"," * all registered plugins are unplugged."," * @chainable"," */","Y.NodeList.prototype.unplug = function() {"," var args = arguments;"," Y.NodeList.each(this, function(node) {"," Y.Node.prototype.unplug.apply(Y.one(node), args);"," });"," return this;","};","","","}, '@VERSION@', {\"requires\": [\"node-base\", \"pluginhost\"]});","","}());"]};
+ __coverage__['build/node-pluginhost/node-pluginhost.js'] = {"path":"build/node-pluginhost/node-pluginhost.js","s":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0},"b":{},"f":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0},"fnMap":{"1":{"name":"(anonymous_1)","line":1,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":46}}},"2":{"name":"(anonymous_2)","line":18,"loc":{"start":{"line":18,"column":14},"end":{"line":18,"column":25}}},"3":{"name":"(anonymous_3)","line":33,"loc":{"start":{"line":33,"column":16},"end":{"line":33,"column":27}}},"4":{"name":"(anonymous_4)","line":60,"loc":{"start":{"line":60,"column":28},"end":{"line":60,"column":39}}},"5":{"name":"(anonymous_5)","line":62,"loc":{"start":{"line":62,"column":26},"end":{"line":62,"column":41}}},"6":{"name":"(anonymous_6)","line":77,"loc":{"start":{"line":77,"column":30},"end":{"line":77,"column":41}}},"7":{"name":"(anonymous_7)","line":79,"loc":{"start":{"line":79,"column":26},"end":{"line":79,"column":41}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":86,"column":59}},"2":{"start":{"line":18,"column":0},"end":{"line":23,"column":2}},"3":{"start":{"line":19,"column":4},"end":{"line":19,"column":34}},"4":{"start":{"line":20,"column":4},"end":{"line":20,"column":25}},"5":{"start":{"line":21,"column":4},"end":{"line":21,"column":43}},"6":{"start":{"line":22,"column":4},"end":{"line":22,"column":18}},"7":{"start":{"line":33,"column":0},"end":{"line":38,"column":2}},"8":{"start":{"line":34,"column":4},"end":{"line":34,"column":34}},"9":{"start":{"line":35,"column":4},"end":{"line":35,"column":25}},"10":{"start":{"line":36,"column":4},"end":{"line":36,"column":45}},"11":{"start":{"line":37,"column":4},"end":{"line":37,"column":18}},"12":{"start":{"line":40,"column":0},"end":{"line":40,"column":45}},"13":{"start":{"line":60,"column":0},"end":{"line":66,"column":2}},"14":{"start":{"line":61,"column":4},"end":{"line":61,"column":25}},"15":{"start":{"line":62,"column":4},"end":{"line":64,"column":7}},"16":{"start":{"line":63,"column":8},"end":{"line":63,"column":55}},"17":{"start":{"line":65,"column":4},"end":{"line":65,"column":16}},"18":{"start":{"line":77,"column":0},"end":{"line":83,"column":2}},"19":{"start":{"line":78,"column":4},"end":{"line":78,"column":25}},"20":{"start":{"line":79,"column":4},"end":{"line":81,"column":7}},"21":{"start":{"line":80,"column":8},"end":{"line":80,"column":57}},"22":{"start":{"line":82,"column":4},"end":{"line":82,"column":16}}},"branchMap":{},"code":["(function () { YUI.add('node-pluginhost', function (Y, NAME) {","","/**"," * @module node"," * @submodule node-pluginhost"," */","","/**"," * Registers plugins to be instantiated at the class level (plugins"," * which should be plugged into every instance of Node by default)."," *"," * @method plug"," * @static"," * @for Node"," * @param {Function | Array} plugin Either the plugin class, an array of plugin classes or an array of objects (with fn and cfg properties defined)"," * @param {Object} config (Optional) If plugin is the plugin class, the configuration for the plugin"," */","Y.Node.plug = function() {"," var args = Y.Array(arguments);"," args.unshift(Y.Node);"," Y.Plugin.Host.plug.apply(Y.Base, args);"," return Y.Node;","};","","/**"," * Unregisters any class level plugins which have been registered by the Node"," *"," * @method unplug"," * @static"," *"," * @param {Function | Array} plugin The plugin class, or an array of plugin classes"," */","Y.Node.unplug = function() {"," var args = Y.Array(arguments);"," args.unshift(Y.Node);"," Y.Plugin.Host.unplug.apply(Y.Base, args);"," return Y.Node;","};","","Y.mix(Y.Node, Y.Plugin.Host, false, null, 1);","","// allow batching of plug/unplug via NodeList","// doesn't use NodeList.importMethod because we need real Nodes (not tmpNode)","/**"," * Adds a plugin to each node in the NodeList."," * This will instantiate the plugin and attach it to the configured namespace on each node"," * @method plug"," * @for NodeList"," * @param P {Function | Object |Array} Accepts the plugin class, or an"," * object with a \"fn\" property specifying the plugin class and"," * a \"cfg\" property specifying the configuration for the Plugin."," * <p>"," * Additionally an Array can also be passed in, with the above function or"," * object values, allowing the user to add multiple plugins in a single call."," * </p>"," * @param config (Optional) If the first argument is the plugin class, the second argument"," * can be the configuration for the plugin."," * @chainable"," */","Y.NodeList.prototype.plug = function() {"," var args = arguments;"," Y.NodeList.each(this, function(node) {"," Y.Node.prototype.plug.apply(Y.one(node), args);"," });"," return this;","};","","/**"," * Removes a plugin from all nodes in the NodeList. This will destroy the"," * plugin instance and delete the namespace each node."," * @method unplug"," * @for NodeList"," * @param {String | Function} plugin The namespace of the plugin, or the plugin class with the static NS namespace property defined. If not provided,"," * all registered plugins are unplugged."," * @chainable"," */","Y.NodeList.prototype.unplug = function() {"," var args = arguments;"," Y.NodeList.each(this, function(node) {"," Y.Node.prototype.unplug.apply(Y.one(node), args);"," });"," return this;","};","","","}, '@VERSION@', {\"requires\": [\"node-base\", \"pluginhost\"]});","","}());"]};
}
var __cov_pN6fN7fUiccsESbeOMj_ow = __coverage__['build/node-pluginhost/node-pluginhost.js'];
-__cov_pN6fN7fUiccsESbeOMj_ow.s['1']++;YUI.add('node-pluginhost',function(Y,NAME){__cov_pN6fN7fUiccsESbeOMj_ow.f['1']++;__cov_pN6fN7fUiccsESbeOMj_ow.s['2']++;Y.Node.plug=function(){__cov_pN6fN7fUiccsESbeOMj_ow.f['2']++;__cov_pN6fN7fUiccsESbeOMj_ow.s['3']++;var args=Y.Array(arguments);__cov_pN6fN7fUiccsESbeOMj_ow.s['4']++;args.unshift(Y.Node);__cov_pN6fN7fUiccsESbeOMj_ow.s['5']++;Y.Plugin.Host.plug.apply(Y.Base,args);__cov_pN6fN7fUiccsESbeOMj_ow.s['6']++;return Y.Node;};__cov_pN6fN7fUiccsESbeOMj_ow.s['7']++;Y.Node.unplug=function(){__cov_pN6fN7fUiccsESbeOMj_ow.f['3']++;__cov_pN6fN7fUiccsESbeOMj_ow.s['8']++;var args=Y.Array(arguments);__cov_pN6fN7fUiccsESbeOMj_ow.s['9']++;args.unshift(Y.Node);__cov_pN6fN7fUiccsESbeOMj_ow.s['10']++;Y.Plugin.Host.unplug.apply(Y.Base,args);__cov_pN6fN7fUiccsESbeOMj_ow.s['11']++;return Y.Node;};__cov_pN6fN7fUiccsESbeOMj_ow.s['12']++;Y.mix(Y.Node,Y.Plugin.Host,false,null,1);__cov_pN6fN7fUiccsESbeOMj_ow.s['13']++;Y.Object.each(Y.Node._instances,function(node){__cov_pN6fN7fUiccsESbeOMj_ow.f['4']++;__cov_pN6fN7fUiccsESbeOMj_ow.s['14']++;Y.Plugin.Host.apply(node);});__cov_pN6fN7fUiccsESbeOMj_ow.s['15']++;Y.NodeList.prototype.plug=function(){__cov_pN6fN7fUiccsESbeOMj_ow.f['5']++;__cov_pN6fN7fUiccsESbeOMj_ow.s['16']++;var args=arguments;__cov_pN6fN7fUiccsESbeOMj_ow.s['17']++;Y.NodeList.each(this,function(node){__cov_pN6fN7fUiccsESbeOMj_ow.f['6']++;__cov_pN6fN7fUiccsESbeOMj_ow.s['18']++;Y.Node.prototype.plug.apply(Y.one(node),args);});__cov_pN6fN7fUiccsESbeOMj_ow.s['19']++;return this;};__cov_pN6fN7fUiccsESbeOMj_ow.s['20']++;Y.NodeList.prototype.unplug=function(){__cov_pN6fN7fUiccsESbeOMj_ow.f['7']++;__cov_pN6fN7fUiccsESbeOMj_ow.s['21']++;var args=arguments;__cov_pN6fN7fUiccsESbeOMj_ow.s['22']++;Y.NodeList.each(this,function(node){__cov_pN6fN7fUiccsESbeOMj_ow.f['8']++;__cov_pN6fN7fUiccsESbeOMj_ow.s['23']++;Y.Node.prototype.unplug.apply(Y.one(node),args);});__cov_pN6fN7fUiccsESbeOMj_ow.s['24']++;return this;};},'@VERSION@',{'requires':['node-base','pluginhost']});
+__cov_pN6fN7fUiccsESbeOMj_ow.s['1']++;YUI.add('node-pluginhost',function(Y,NAME){__cov_pN6fN7fUiccsESbeOMj_ow.f['1']++;__cov_pN6fN7fUiccsESbeOMj_ow.s['2']++;Y.Node.plug=function(){__cov_pN6fN7fUiccsESbeOMj_ow.f['2']++;__cov_pN6fN7fUiccsESbeOMj_ow.s['3']++;var args=Y.Array(arguments);__cov_pN6fN7fUiccsESbeOMj_ow.s['4']++;args.unshift(Y.Node);__cov_pN6fN7fUiccsESbeOMj_ow.s['5']++;Y.Plugin.Host.plug.apply(Y.Base,args);__cov_pN6fN7fUiccsESbeOMj_ow.s['6']++;return Y.Node;};__cov_pN6fN7fUiccsESbeOMj_ow.s['7']++;Y.Node.unplug=function(){__cov_pN6fN7fUiccsESbeOMj_ow.f['3']++;__cov_pN6fN7fUiccsESbeOMj_ow.s['8']++;var args=Y.Array(arguments);__cov_pN6fN7fUiccsESbeOMj_ow.s['9']++;args.unshift(Y.Node);__cov_pN6fN7fUiccsESbeOMj_ow.s['10']++;Y.Plugin.Host.unplug.apply(Y.Base,args);__cov_pN6fN7fUiccsESbeOMj_ow.s['11']++;return Y.Node;};__cov_pN6fN7fUiccsESbeOMj_ow.s['12']++;Y.mix(Y.Node,Y.Plugin.Host,false,null,1);__cov_pN6fN7fUiccsESbeOMj_ow.s['13']++;Y.NodeList.prototype.plug=function(){__cov_pN6fN7fUiccsESbeOMj_ow.f['4']++;__cov_pN6fN7fUiccsESbeOMj_ow.s['14']++;var args=arguments;__cov_pN6fN7fUiccsESbeOMj_ow.s['15']++;Y.NodeList.each(this,function(node){__cov_pN6fN7fUiccsESbeOMj_ow.f['5']++;__cov_pN6fN7fUiccsESbeOMj_ow.s['16']++;Y.Node.prototype.plug.apply(Y.one(node),args);});__cov_pN6fN7fUiccsESbeOMj_ow.s['17']++;return this;};__cov_pN6fN7fUiccsESbeOMj_ow.s['18']++;Y.NodeList.prototype.unplug=function(){__cov_pN6fN7fUiccsESbeOMj_ow.f['6']++;__cov_pN6fN7fUiccsESbeOMj_ow.s['19']++;var args=arguments;__cov_pN6fN7fUiccsESbeOMj_ow.s['20']++;Y.NodeList.each(this,function(node){__cov_pN6fN7fUiccsESbeOMj_ow.f['7']++;__cov_pN6fN7fUiccsESbeOMj_ow.s['21']++;Y.Node.prototype.unplug.apply(Y.one(node),args);});__cov_pN6fN7fUiccsESbeOMj_ow.s['22']++;return this;};},'@VERSION@',{'requires':['node-base','pluginhost']});
View
5 build/node-pluginhost/node-pluginhost-debug.js
@@ -39,11 +39,6 @@ Y.Node.unplug = function() {
Y.mix(Y.Node, Y.Plugin.Host, false, null, 1);
-// run PluginHost constructor on cached Node instances
-Y.Object.each(Y.Node._instances, function (node) {
- Y.Plugin.Host.apply(node);
-});
-
// allow batching of plug/unplug via NodeList
// doesn't use NodeList.importMethod because we need real Nodes (not tmpNode)
/**
View
2  build/node-pluginhost/node-pluginhost-min.js
@@ -1 +1 @@
-YUI.add("node-pluginhost",function(e,t){e.Node.plug=function(){var t=e.Array(arguments);return t.unshift(e.Node),e.Plugin.Host.plug.apply(e.Base,t),e.Node},e.Node.unplug=function(){var t=e.Array(arguments);return t.unshift(e.Node),e.Plugin.Host.unplug.apply(e.Base,t),e.Node},e.mix(e.Node,e.Plugin.Host,!1,null,1),e.Object.each(e.Node._instances,function(t){e.Plugin.Host.apply(t)}),e.NodeList.prototype.plug=function(){var t=arguments;return e.NodeList.each(this,function(n){e.Node.prototype.plug.apply(e.one(n),t)}),this},e.NodeList.prototype.unplug=function(){var t=arguments;return e.NodeList.each(this,function(n){e.Node.prototype.unplug.apply(e.one(n),t)}),this}},"@VERSION@",{requires:["node-base","pluginhost"]});
+YUI.add("node-pluginhost",function(e,t){e.Node.plug=function(){var t=e.Array(arguments);return t.unshift(e.Node),e.Plugin.Host.plug.apply(e.Base,t),e.Node},e.Node.unplug=function(){var t=e.Array(arguments);return t.unshift(e.Node),e.Plugin.Host.unplug.apply(e.Base,t),e.Node},e.mix(e.Node,e.Plugin.Host,!1,null,1),e.NodeList.prototype.plug=function(){var t=arguments;return e.NodeList.each(this,function(n){e.Node.prototype.plug.apply(e.one(n),t)}),this},e.NodeList.prototype.unplug=function(){var t=arguments;return e.NodeList.each(this,function(n){e.Node.prototype.unplug.apply(e.one(n),t)}),this}},"@VERSION@",{requires:["node-base","pluginhost"]});
View
5 build/node-pluginhost/node-pluginhost.js
@@ -39,11 +39,6 @@ Y.Node.unplug = function() {
Y.mix(Y.Node, Y.Plugin.Host, false, null, 1);
-// run PluginHost constructor on cached Node instances
-Y.Object.each(Y.Node._instances, function (node) {
- Y.Plugin.Host.apply(node);
-});
-
// allow batching of plug/unplug via NodeList
// doesn't use NodeList.importMethod because we need real Nodes (not tmpNode)
/**
View
4 build/pluginhost-base/pluginhost-base-coverage.js
@@ -1,6 +1,6 @@
if (typeof __coverage__ === 'undefined') { __coverage__ = {}; }
if (!__coverage__['build/pluginhost-base/pluginhost-base.js']) {
- __coverage__['build/pluginhost-base/pluginhost-base.js'] = {"path":"build/pluginhost-base/pluginhost-base.js","s":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0},"b":{"1":[0,0],"2":[0,0],"3":[0,0],"4":[0,0],"5":[0,0],"6":[0,0],"7":[0,0],"8":[0,0],"9":[0,0],"10":[0,0],"11":[0,0],"12":[0,0,0],"13":[0,0],"14":[0,0],"15":[0,0],"16":[0,0],"17":[0,0],"18":[0,0],"19":[0,0],"20":[0,0]},"f":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0},"fnMap":{"1":{"name":"(anonymous_1)","line":1,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":46}}},"2":{"name":"PluginHost","line":38,"loc":{"start":{"line":38,"column":4},"end":{"line":38,"column":26}}},"3":{"name":"(anonymous_3)","line":61,"loc":{"start":{"line":61,"column":14},"end":{"line":61,"column":39}}},"4":{"name":"(anonymous_4)","line":106,"loc":{"start":{"line":106,"column":16},"end":{"line":106,"column":33}}},"5":{"name":"(anonymous_5)","line":146,"loc":{"start":{"line":146,"column":20},"end":{"line":146,"column":33}}},"6":{"name":"(anonymous_6)","line":160,"loc":{"start":{"line":160,"column":22},"end":{"line":160,"column":39}}},"7":{"name":"(anonymous_7)","line":173,"loc":{"start":{"line":173,"column":25},"end":{"line":173,"column":36}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":181,"column":44}},"2":{"start":{"line":36,"column":4},"end":{"line":36,"column":19}},"3":{"start":{"line":38,"column":4},"end":{"line":40,"column":5}},"4":{"start":{"line":39,"column":8},"end":{"line":39,"column":27}},"5":{"start":{"line":42,"column":4},"end":{"line":176,"column":6}},"6":{"start":{"line":62,"column":12},"end":{"line":62,"column":26}},"7":{"start":{"line":64,"column":12},"end":{"line":92,"column":13}},"8":{"start":{"line":65,"column":16},"end":{"line":67,"column":17}},"9":{"start":{"line":66,"column":20},"end":{"line":66,"column":41}},"10":{"start":{"line":69,"column":16},"end":{"line":72,"column":17}},"11":{"start":{"line":70,"column":20},"end":{"line":70,"column":40}},"12":{"start":{"line":71,"column":20},"end":{"line":71,"column":39}},"13":{"start":{"line":75,"column":16},"end":{"line":91,"column":17}},"14":{"start":{"line":76,"column":20},"end":{"line":76,"column":35}},"15":{"start":{"line":78,"column":20},"end":{"line":78,"column":42}},"16":{"start":{"line":79,"column":20},"end":{"line":79,"column":39}},"17":{"start":{"line":81,"column":20},"end":{"line":90,"column":21}},"18":{"start":{"line":83,"column":24},"end":{"line":85,"column":25}},"19":{"start":{"line":84,"column":28},"end":{"line":84,"column":54}},"20":{"start":{"line":88,"column":24},"end":{"line":88,"column":54}},"21":{"start":{"line":89,"column":24},"end":{"line":89,"column":51}},"22":{"start":{"line":93,"column":12},"end":{"line":93,"column":24}},"23":{"start":{"line":107,"column":12},"end":{"line":108,"column":40}},"24":{"start":{"line":110,"column":12},"end":{"line":135,"column":13}},"25":{"start":{"line":111,"column":16},"end":{"line":116,"column":17}},"26":{"start":{"line":112,"column":20},"end":{"line":112,"column":35}},"27":{"start":{"line":113,"column":20},"end":{"line":115,"column":21}},"28":{"start":{"line":114,"column":24},"end":{"line":114,"column":34}},"29":{"start":{"line":118,"column":16},"end":{"line":128,"column":17}},"30":{"start":{"line":119,"column":20},"end":{"line":124,"column":21}},"31":{"start":{"line":120,"column":24},"end":{"line":122,"column":25}},"32":{"start":{"line":121,"column":28},"end":{"line":121,"column":47}},"33":{"start":{"line":123,"column":24},"end":{"line":123,"column":40}},"34":{"start":{"line":125,"column":20},"end":{"line":127,"column":21}},"35":{"start":{"line":126,"column":24},"end":{"line":126,"column":43}},"36":{"start":{"line":130,"column":16},"end":{"line":134,"column":17}},"37":{"start":{"line":131,"column":20},"end":{"line":133,"column":21}},"38":{"start":{"line":132,"column":24},"end":{"line":132,"column":40}},"39":{"start":{"line":136,"column":12},"end":{"line":136,"column":24}},"40":{"start":{"line":147,"column":12},"end":{"line":147,"column":51}},"41":{"start":{"line":161,"column":12},"end":{"line":161,"column":48}},"42":{"start":{"line":163,"column":12},"end":{"line":165,"column":13}},"43":{"start":{"line":164,"column":16},"end":{"line":164,"column":48}},"44":{"start":{"line":174,"column":12},"end":{"line":174,"column":26}},"45":{"start":{"line":178,"column":4},"end":{"line":178,"column":44}}},"branchMap":{"1":{"line":64,"type":"if","locations":[{"start":{"line":64,"column":12},"end":{"line":64,"column":12}},{"start":{"line":64,"column":12},"end":{"line":64,"column":12}}]},"2":{"line":69,"type":"if","locations":[{"start":{"line":69,"column":16},"end":{"line":69,"column":16}},{"start":{"line":69,"column":16},"end":{"line":69,"column":16}}]},"3":{"line":69,"type":"binary-expr","locations":[{"start":{"line":69,"column":20},"end":{"line":69,"column":26}},{"start":{"line":69,"column":30},"end":{"line":69,"column":51}}]},"4":{"line":75,"type":"if","locations":[{"start":{"line":75,"column":16},"end":{"line":75,"column":16}},{"start":{"line":75,"column":16},"end":{"line":75,"column":16}}]},"5":{"line":75,"type":"binary-expr","locations":[{"start":{"line":75,"column":20},"end":{"line":75,"column":26}},{"start":{"line":75,"column":30},"end":{"line":75,"column":39}}]},"6":{"line":78,"type":"binary-expr","locations":[{"start":{"line":78,"column":29},"end":{"line":78,"column":35}},{"start":{"line":78,"column":39},"end":{"line":78,"column":41}}]},"7":{"line":81,"type":"if","locations":[{"start":{"line":81,"column":20},"end":{"line":81,"column":20}},{"start":{"line":81,"column":20},"end":{"line":81,"column":20}}]},"8":{"line":83,"type":"if","locations":[{"start":{"line":83,"column":24},"end":{"line":83,"column":24}},{"start":{"line":83,"column":24},"end":{"line":83,"column":24}}]},"9":{"line":110,"type":"if","locations":[{"start":{"line":110,"column":12},"end":{"line":110,"column":12}},{"start":{"line":110,"column":12},"end":{"line":110,"column":12}}]},"10":{"line":111,"type":"if","locations":[{"start":{"line":111,"column":16},"end":{"line":111,"column":16}},{"start":{"line":111,"column":16},"end":{"line":111,"column":16}}]},"11":{"line":113,"type":"if","locations":[{"start":{"line":113,"column":20},"end":{"line":113,"column":20}},{"start":{"line":113,"column":20},"end":{"line":113,"column":20}}]},"12":{"line":113,"type":"binary-expr","locations":[{"start":{"line":113,"column":24},"end":{"line":113,"column":26}},{"start":{"line":113,"column":31},"end":{"line":113,"column":43}},{"start":{"line":113,"column":47},"end":{"line":113,"column":69}}]},"13":{"line":118,"type":"if","locations":[{"start":{"line":118,"column":16},"end":{"line":118,"column":16}},{"start":{"line":118,"column":16},"end":{"line":118,"column":16}}]},"14":{"line":119,"type":"if","locations":[{"start":{"line":119,"column":20},"end":{"line":119,"column":20}},{"start":{"line":119,"column":20},"end":{"line":119,"column":20}}]},"15":{"line":120,"type":"if","locations":[{"start":{"line":120,"column":24},"end":{"line":120,"column":24}},{"start":{"line":120,"column":24},"end":{"line":120,"column":24}}]},"16":{"line":125,"type":"if","locations":[{"start":{"line":125,"column":20},"end":{"line":125,"column":20}},{"start":{"line":125,"column":20},"end":{"line":125,"column":20}}]},"17":{"line":131,"type":"if","locations":[{"start":{"line":131,"column":20},"end":{"line":131,"column":20}},{"start":{"line":131,"column":20},"end":{"line":131,"column":20}}]},"18":{"line":147,"type":"binary-expr","locations":[{"start":{"line":147,"column":20},"end":{"line":147,"column":37}},{"start":{"line":147,"column":41},"end":{"line":147,"column":49}}]},"19":{"line":161,"type":"binary-expr","locations":[{"start":{"line":161,"column":28},"end":{"line":161,"column":41}},{"start":{"line":161,"column":45},"end":{"line":161,"column":47}}]},"20":{"line":163,"type":"if","locations":[{"start":{"line":163,"column":12},"end":{"line":163,"column":12}},{"start":{"line":163,"column":12},"end":{"line":163,"column":12}}]}},"code":["(function () { YUI.add('pluginhost-base', function (Y, NAME) {",""," /**"," * Provides the augmentable PluginHost interface, which can be added to any class."," * @module pluginhost"," */",""," /**"," * Provides the augmentable PluginHost interface, which can be added to any class."," * @module pluginhost-base"," */",""," /**"," * <p>"," * An augmentable class, which provides the augmented class with the ability to host plugins."," * It adds <a href=\"#method_plug\">plug</a> and <a href=\"#method_unplug\">unplug</a> methods to the augmented class, which can"," * be used to add or remove plugins from instances of the class."," * </p>"," *"," * <p>Plugins can also be added through the constructor configuration object passed to the host class' constructor using"," * the \"plugins\" property. Supported values for the \"plugins\" property are those defined by the <a href=\"#method_plug\">plug</a> method."," *"," * For example the following code would add the AnimPlugin and IOPlugin to Overlay (the plugin host):"," * <xmp>"," * var o = new Overlay({plugins: [ AnimPlugin, {fn:IOPlugin, cfg:{section:\"header\"}}]});"," * </xmp>"," * </p>"," * <p>"," * Plug.Host's protected <a href=\"#method_initPlugins\">_initPlugins</a> and <a href=\"#method_destroyPlugins\">_destroyPlugins</a>"," * methods should be invoked by the host class at the appropriate point in the host's lifecyle."," * </p>"," *"," * @class Plugin.Host"," */",""," var L = Y.Lang;",""," function PluginHost() {"," this._plugins = {};"," }",""," PluginHost.prototype = {",""," /**"," * Adds a plugin to the host object. This will instantiate the"," * plugin and attach it to the configured namespace on the host object."," *"," * @method plug"," * @chainable"," * @param P {Function | Object |Array} Accepts the plugin class, or an"," * object with a \"fn\" property specifying the plugin class and"," * a \"cfg\" property specifying the configuration for the Plugin."," * <p>"," * Additionally an Array can also be passed in, with the above function or"," * object values, allowing the user to add multiple plugins in a single call."," * </p>"," * @param config (Optional) If the first argument is the plugin class, the second argument"," * can be the configuration for the plugin."," * @return {Base} A reference to the host object"," */"," plug: function(Plugin, config) {"," var i, ln, ns;",""," if (L.isArray(Plugin)) {"," for (i = 0, ln = Plugin.length; i < ln; i++) {"," this.plug(Plugin[i]);"," }"," } else {"," if (Plugin && !L.isFunction(Plugin)) {"," config = Plugin.cfg;"," Plugin = Plugin.fn;"," }",""," // Plugin should be fn by now"," if (Plugin && Plugin.NS) {"," ns = Plugin.NS;",""," config = config || {};"," config.host = this;",""," if (this.hasPlugin(ns)) {"," // Update config"," if (this[ns].setAttrs) {"," this[ns].setAttrs(config);"," }"," } else {"," // Create new instance"," this[ns] = new Plugin(config);"," this._plugins[ns] = Plugin;"," }"," }"," }"," return this;"," },",""," /**"," * Removes a plugin from the host object. This will destroy the"," * plugin instance and delete the namespace from the host object."," *"," * @method unplug"," * @param {String | Function} plugin The namespace of the plugin, or the plugin class with the static NS namespace property defined. If not provided,"," * all registered plugins are unplugged."," * @return {Base} A reference to the host object"," * @chainable"," */"," unplug: function(plugin) {"," var ns = plugin,"," plugins = this._plugins;",""," if (plugin) {"," if (L.isFunction(plugin)) {"," ns = plugin.NS;"," if (ns && (!plugins[ns] || plugins[ns] !== plugin)) {"," ns = null;"," }"," }",""," if (ns) {"," if (this[ns]) {"," if (this[ns].destroy) {"," this[ns].destroy();"," }"," delete this[ns];"," }"," if (plugins[ns]) {"," delete plugins[ns];"," }"," }"," } else {"," for (ns in this._plugins) {"," if (this._plugins.hasOwnProperty(ns)) {"," this.unplug(ns);"," }"," }"," }"," return this;"," },",""," /**"," * Determines if a plugin has plugged into this host."," *"," * @method hasPlugin"," * @param {String} ns The plugin's namespace"," * @return {Plugin} Returns a truthy value (the plugin instance) if present, or undefined if not."," */"," hasPlugin : function(ns) {"," return (this._plugins[ns] && this[ns]);"," },",""," /**"," * Initializes static plugins registered on the host (using the"," * Base.plug static method) and any plugins passed to the"," * instance through the \"plugins\" configuration property."," *"," * @method _initPlugins"," * @param {Object} config The configuration object with property name/value pairs."," * @private"," */",""," _initPlugins: function(config) {"," this._plugins = this._plugins || {};",""," if (this._initConfigPlugins) {"," this._initConfigPlugins(config);"," }"," },",""," /**"," * Unplugs and destroys all plugins on the host"," * @method _destroyPlugins"," * @private"," */"," _destroyPlugins: function() {"," this.unplug();"," }"," };",""," Y.namespace(\"Plugin\").Host = PluginHost;","","","}, '@VERSION@', {\"requires\": [\"yui-base\"]});","","}());"]};
+ __coverage__['build/pluginhost-base/pluginhost-base.js'] = {"path":"build/pluginhost-base/pluginhost-base.js","s":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0},"b":{"1":[0,0],"2":[0,0],"3":[0,0],"4":[0,0],"5":[0,0],"6":[0,0],"7":[0,0],"8":[0,0],"9":[0,0],"10":[0,0],"11":[0,0],"12":[0,0],"13":[0,0],"14":[0,0,0],"15":[0,0],"16":[0,0],"17":[0,0],"18":[0,0],"19":[0,0],"20":[0,0,0],"21":[0,0],"22":[0,0]},"f":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0},"fnMap":{"1":{"name":"(anonymous_1)","line":1,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":46}}},"2":{"name":"PluginHost","line":38,"loc":{"start":{"line":38,"column":4},"end":{"line":38,"column":26}}},"3":{"name":"(anonymous_3)","line":61,"loc":{"start":{"line":61,"column":14},"end":{"line":61,"column":39}}},"4":{"name":"(anonymous_4)","line":108,"loc":{"start":{"line":108,"column":16},"end":{"line":108,"column":33}}},"5":{"name":"(anonymous_5)","line":151,"loc":{"start":{"line":151,"column":20},"end":{"line":151,"column":33}}},"6":{"name":"(anonymous_6)","line":165,"loc":{"start":{"line":165,"column":22},"end":{"line":165,"column":39}}},"7":{"name":"(anonymous_7)","line":178,"loc":{"start":{"line":178,"column":25},"end":{"line":178,"column":36}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":186,"column":44}},"2":{"start":{"line":36,"column":4},"end":{"line":36,"column":19}},"3":{"start":{"line":38,"column":4},"end":{"line":40,"column":5}},"4":{"start":{"line":42,"column":4},"end":{"line":181,"column":6}},"5":{"start":{"line":62,"column":12},"end":{"line":62,"column":26}},"6":{"start":{"line":64,"column":12},"end":{"line":64,"column":48}},"7":{"start":{"line":66,"column":12},"end":{"line":94,"column":13}},"8":{"start":{"line":67,"column":16},"end":{"line":69,"column":17}},"9":{"start":{"line":68,"column":20},"end":{"line":68,"column":41}},"10":{"start":{"line":71,"column":16},"end":{"line":74,"column":17}},"11":{"start":{"line":72,"column":20},"end":{"line":72,"column":40}},"12":{"start":{"line":73,"column":20},"end":{"line":73,"column":39}},"13":{"start":{"line":77,"column":16},"end":{"line":93,"column":17}},"14":{"start":{"line":78,"column":20},"end":{"line":78,"column":35}},"15":{"start":{"line":80,"column":20},"end":{"line":80,"column":42}},"16":{"start":{"line":81,"column":20},"end":{"line":81,"column":39}},"17":{"start":{"line":83,"column":20},"end":{"line":92,"column":21}},"18":{"start":{"line":85,"column":24},"end":{"line":87,"column":25}},"19":{"start":{"line":86,"column":28},"end":{"line":86,"column":54}},"20":{"start":{"line":90,"column":24},"end":{"line":90,"column":54}},"21":{"start":{"line":91,"column":24},"end":{"line":91,"column":51}},"22":{"start":{"line":95,"column":12},"end":{"line":95,"column":24}},"23":{"start":{"line":109,"column":12},"end":{"line":110,"column":24}},"24":{"start":{"line":112,"column":12},"end":{"line":112,"column":48}},"25":{"start":{"line":113,"column":12},"end":{"line":113,"column":36}},"26":{"start":{"line":115,"column":12},"end":{"line":140,"column":13}},"27":{"start":{"line":116,"column":16},"end":{"line":121,"column":17}},"28":{"start":{"line":117,"column":20},"end":{"line":117,"column":35}},"29":{"start":{"line":118,"column":20},"end":{"line":120,"column":21}},"30":{"start":{"line":119,"column":24},"end":{"line":119,"column":34}},"31":{"start":{"line":123,"column":16},"end":{"line":133,"column":17}},"32":{"start":{"line":124,"column":20},"end":{"line":129,"column":21}},"33":{"start":{"line":125,"column":24},"end":{"line":127,"column":25}},"34":{"start":{"line":126,"column":28},"end":{"line":126,"column":47}},"35":{"start":{"line":128,"column":24},"end":{"line":128,"column":40}},"36":{"start":{"line":130,"column":20},"end":{"line":132,"column":21}},"37":{"start":{"line":131,"column":24},"end":{"line":131,"column":43}},"38":{"start":{"line":135,"column":16},"end":{"line":139,"column":17}},"39":{"start":{"line":136,"column":20},"end":{"line":138,"column":21}},"40":{"start":{"line":137,"column":24},"end":{"line":137,"column":40}},"41":{"start":{"line":141,"column":12},"end":{"line":141,"column":24}},"42":{"start":{"line":152,"column":12},"end":{"line":152,"column":68}},"43":{"start":{"line":166,"column":12},"end":{"line":166,"column":48}},"44":{"start":{"line":168,"column":12},"end":{"line":170,"column":13}},"45":{"start":{"line":169,"column":16},"end":{"line":169,"column":48}},"46":{"start":{"line":179,"column":12},"end":{"line":179,"column":26}},"47":{"start":{"line":183,"column":4},"end":{"line":183,"column":44}}},"branchMap":{"1":{"line":64,"type":"binary-expr","locations":[{"start":{"line":64,"column":28},"end":{"line":64,"column":41}},{"start":{"line":64,"column":45},"end":{"line":64,"column":47}}]},"2":{"line":66,"type":"if","locations":[{"start":{"line":66,"column":12},"end":{"line":66,"column":12}},{"start":{"line":66,"column":12},"end":{"line":66,"column":12}}]},"3":{"line":71,"type":"if","locations":[{"start":{"line":71,"column":16},"end":{"line":71,"column":16}},{"start":{"line":71,"column":16},"end":{"line":71,"column":16}}]},"4":{"line":71,"type":"binary-expr","locations":[{"start":{"line":71,"column":20},"end":{"line":71,"column":26}},{"start":{"line":71,"column":30},"end":{"line":71,"column":51}}]},"5":{"line":77,"type":"if","locations":[{"start":{"line":77,"column":16},"end":{"line":77,"column":16}},{"start":{"line":77,"column":16},"end":{"line":77,"column":16}}]},"6":{"line":77,"type":"binary-expr","locations":[{"start":{"line":77,"column":20},"end":{"line":77,"column":26}},{"start":{"line":77,"column":30},"end":{"line":77,"column":39}}]},"7":{"line":80,"type":"binary-expr","locations":[{"start":{"line":80,"column":29},"end":{"line":80,"column":35}},{"start":{"line":80,"column":39},"end":{"line":80,"column":41}}]},"8":{"line":83,"type":"if","locations":[{"start":{"line":83,"column":20},"end":{"line":83,"column":20}},{"start":{"line":83,"column":20},"end":{"line":83,"column":20}}]},"9":{"line":85,"type":"if","locations":[{"start":{"line":85,"column":24},"end":{"line":85,"column":24}},{"start":{"line":85,"column":24},"end":{"line":85,"column":24}}]},"10":{"line":112,"type":"binary-expr","locations":[{"start":{"line":112,"column":28},"end":{"line":112,"column":41}},{"start":{"line":112,"column":45},"end":{"line":112,"column":47}}]},"11":{"line":115,"type":"if","locations":[{"start":{"line":115,"column":12},"end":{"line":115,"column":12}},{"start":{"line":115,"column":12},"end":{"line":115,"column":12}}]},"12":{"line":116,"type":"if","locations":[{"start":{"line":116,"column":16},"end":{"line":116,"column":16}},{"start":{"line":116,"column":16},"end":{"line":116,"column":16}}]},"13":{"line":118,"type":"if","locations":[{"start":{"line":118,"column":20},"end":{"line":118,"column":20}},{"start":{"line":118,"column":20},"end":{"line":118,"column":20}}]},"14":{"line":118,"type":"binary-expr","locations":[{"start":{"line":118,"column":24},"end":{"line":118,"column":26}},{"start":{"line":118,"column":31},"end":{"line":118,"column":43}},{"start":{"line":118,"column":47},"end":{"line":118,"column":69}}]},"15":{"line":123,"type":"if","locations":[{"start":{"line":123,"column":16},"end":{"line":123,"column":16}},{"start":{"line":123,"column":16},"end":{"line":123,"column":16}}]},"16":{"line":124,"type":"if","locations":[{"start":{"line":124,"column":20},"end":{"line":124,"column":20}},{"start":{"line":124,"column":20},"end":{"line":124,"column":20}}]},"17":{"line":125,"type":"if","locations":[{"start":{"line":125,"column":24},"end":{"line":125,"column":24}},{"start":{"line":125,"column":24},"end":{"line":125,"column":24}}]},"18":{"line":130,"type":"if","locations":[{"start":{"line":130,"column":20},"end":{"line":130,"column":20}},{"start":{"line":130,"column":20},"end":{"line":130,"column":20}}]},"19":{"line":136,"type":"if","locations":[{"start":{"line":136,"column":20},"end":{"line":136,"column":20}},{"start":{"line":136,"column":20},"end":{"line":136,"column":20}}]},"20":{"line":152,"type":"binary-expr","locations":[{"start":{"line":152,"column":20},"end":{"line":152,"column":33}},{"start":{"line":152,"column":37},"end":{"line":152,"column":54}},{"start":{"line":152,"column":58},"end":{"line":152,"column":66}}]},"21":{"line":166,"type":"binary-expr","locations":[{"start":{"line":166,"column":28},"end":{"line":166,"column":41}},{"start":{"line":166,"column":45},"end":{"line":166,"column":47}}]},"22":{"line":168,"type":"if","locations":[{"start":{"line":168,"column":12},"end":{"line":168,"column":12}},{"start":{"line":168,"column":12},"end":{"line":168,"column":12}}]}},"code":["(function () { YUI.add('pluginhost-base', function (Y, NAME) {",""," /**"," * Provides the augmentable PluginHost interface, which can be added to any class."," * @module pluginhost"," */",""," /**"," * Provides the augmentable PluginHost interface, which can be added to any class."," * @module pluginhost-base"," */",""," /**"," * <p>"," * An augmentable class, which provides the augmented class with the ability to host plugins."," * It adds <a href=\"#method_plug\">plug</a> and <a href=\"#method_unplug\">unplug</a> methods to the augmented class, which can"," * be used to add or remove plugins from instances of the class."," * </p>"," *"," * <p>Plugins can also be added through the constructor configuration object passed to the host class' constructor using"," * the \"plugins\" property. Supported values for the \"plugins\" property are those defined by the <a href=\"#method_plug\">plug</a> method."," *"," * For example the following code would add the AnimPlugin and IOPlugin to Overlay (the plugin host):"," * <xmp>"," * var o = new Overlay({plugins: [ AnimPlugin, {fn:IOPlugin, cfg:{section:\"header\"}}]});"," * </xmp>"," * </p>"," * <p>"," * Plug.Host's protected <a href=\"#method_initPlugins\">_initPlugins</a> and <a href=\"#method_destroyPlugins\">_destroyPlugins</a>"," * methods should be invoked by the host class at the appropriate point in the host's lifecyle."," * </p>"," *"," * @class Plugin.Host"," */",""," var L = Y.Lang;",""," function PluginHost() {"," // do not initialize this._plugins, because Y.Node's may have been created before Y.PluginHost was loaded"," }",""," PluginHost.prototype = {",""," /**"," * Adds a plugin to the host object. This will instantiate the"," * plugin and attach it to the configured namespace on the host object."," *"," * @method plug"," * @chainable"," * @param P {Function | Object |Array} Accepts the plugin class, or an"," * object with a \"fn\" property specifying the plugin class and"," * a \"cfg\" property specifying the configuration for the Plugin."," * <p>"," * Additionally an Array can also be passed in, with the above function or"," * object values, allowing the user to add multiple plugins in a single call."," * </p>"," * @param config (Optional) If the first argument is the plugin class, the second argument"," * can be the configuration for the plugin."," * @return {Base} A reference to the host object"," */"," plug: function(Plugin, config) {"," var i, ln, ns;",""," this._plugins = this._plugins || {};",""," if (L.isArray(Plugin)) {"," for (i = 0, ln = Plugin.length; i < ln; i++) {"," this.plug(Plugin[i]);"," }"," } else {"," if (Plugin && !L.isFunction(Plugin)) {"," config = Plugin.cfg;"," Plugin = Plugin.fn;"," }",""," // Plugin should be fn by now"," if (Plugin && Plugin.NS) {"," ns = Plugin.NS;",""," config = config || {};"," config.host = this;",""," if (this.hasPlugin(ns)) {"," // Update config"," if (this[ns].setAttrs) {"," this[ns].setAttrs(config);"," }"," } else {"," // Create new instance"," this[ns] = new Plugin(config);"," this._plugins[ns] = Plugin;"," }"," }"," }"," return this;"," },",""," /**"," * Removes a plugin from the host object. This will destroy the"," * plugin instance and delete the namespace from the host object."," *"," * @method unplug"," * @param {String | Function} plugin The namespace of the plugin, or the plugin class with the static NS namespace property defined. If not provided,"," * all registered plugins are unplugged."," * @return {Base} A reference to the host object"," * @chainable"," */"," unplug: function(plugin) {"," var ns = plugin,"," plugins;",""," this._plugins = this._plugins || {};"," plugins = this._plugins;",""," if (plugin) {"," if (L.isFunction(plugin)) {"," ns = plugin.NS;"," if (ns && (!plugins[ns] || plugins[ns] !== plugin)) {"," ns = null;"," }"," }",""," if (ns) {"," if (this[ns]) {"," if (this[ns].destroy) {"," this[ns].destroy();"," }"," delete this[ns];"," }"," if (plugins[ns]) {"," delete plugins[ns];"," }"," }"," } else {"," for (ns in this._plugins) {"," if (this._plugins.hasOwnProperty(ns)) {"," this.unplug(ns);"," }"," }"," }"," return this;"," },",""," /**"," * Determines if a plugin has plugged into this host."," *"," * @method hasPlugin"," * @param {String} ns The plugin's namespace"," * @return {Plugin} Returns a truthy value (the plugin instance) if present, or undefined if not."," */"," hasPlugin : function(ns) {"," return (this._plugins && this._plugins[ns] && this[ns]);"," },",""," /**"," * Initializes static plugins registered on the host (using the"," * Base.plug static method) and any plugins passed to the"," * instance through the \"plugins\" configuration property."," *"," * @method _initPlugins"," * @param {Object} config The configuration object with property name/value pairs."," * @private"," */",""," _initPlugins: function(config) {"," this._plugins = this._plugins || {};",""," if (this._initConfigPlugins) {"," this._initConfigPlugins(config);"," }"," },",""," /**"," * Unplugs and destroys all plugins on the host"," * @method _destroyPlugins"," * @private"," */"," _destroyPlugins: function() {"," this.unplug();"," }"," };",""," Y.namespace(\"Plugin\").Host = PluginHost;","","","}, '@VERSION@', {\"requires\": [\"yui-base\"]});","","}());"]};
}
var __cov_dDY1oPzWlroRs49oPPuh3Q = __coverage__['build/pluginhost-base/pluginhost-base.js'];
-__cov_dDY1oPzWlroRs49oPPuh3Q.s['1']++;YUI.add('pluginhost-base',function(Y,NAME){__cov_dDY1oPzWlroRs49oPPuh3Q.f['1']++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['2']++;var L=Y.Lang;__cov_dDY1oPzWlroRs49oPPuh3Q.s['3']++;function PluginHost(){__cov_dDY1oPzWlroRs49oPPuh3Q.f['2']++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['4']++;this._plugins={};}__cov_dDY1oPzWlroRs49oPPuh3Q.s['5']++;PluginHost.prototype={plug:function(Plugin,config){__cov_dDY1oPzWlroRs49oPPuh3Q.f['3']++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['6']++;var i,ln,ns;__cov_dDY1oPzWlroRs49oPPuh3Q.s['7']++;if(L.isArray(Plugin)){__cov_dDY1oPzWlroRs49oPPuh3Q.b['1'][0]++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['8']++;for(i=0,ln=Plugin.length;i<ln;i++){__cov_dDY1oPzWlroRs49oPPuh3Q.s['9']++;this.plug(Plugin[i]);}}else{__cov_dDY1oPzWlroRs49oPPuh3Q.b['1'][1]++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['10']++;if((__cov_dDY1oPzWlroRs49oPPuh3Q.b['3'][0]++,Plugin)&&(__cov_dDY1oPzWlroRs49oPPuh3Q.b['3'][1]++,!L.isFunction(Plugin))){__cov_dDY1oPzWlroRs49oPPuh3Q.b['2'][0]++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['11']++;config=Plugin.cfg;__cov_dDY1oPzWlroRs49oPPuh3Q.s['12']++;Plugin=Plugin.fn;}else{__cov_dDY1oPzWlroRs49oPPuh3Q.b['2'][1]++;}__cov_dDY1oPzWlroRs49oPPuh3Q.s['13']++;if((__cov_dDY1oPzWlroRs49oPPuh3Q.b['5'][0]++,Plugin)&&(__cov_dDY1oPzWlroRs49oPPuh3Q.b['5'][1]++,Plugin.NS)){__cov_dDY1oPzWlroRs49oPPuh3Q.b['4'][0]++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['14']++;ns=Plugin.NS;__cov_dDY1oPzWlroRs49oPPuh3Q.s['15']++;config=(__cov_dDY1oPzWlroRs49oPPuh3Q.b['6'][0]++,config)||(__cov_dDY1oPzWlroRs49oPPuh3Q.b['6'][1]++,{});__cov_dDY1oPzWlroRs49oPPuh3Q.s['16']++;config.host=this;__cov_dDY1oPzWlroRs49oPPuh3Q.s['17']++;if(this.hasPlugin(ns)){__cov_dDY1oPzWlroRs49oPPuh3Q.b['7'][0]++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['18']++;if(this[ns].setAttrs){__cov_dDY1oPzWlroRs49oPPuh3Q.b['8'][0]++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['19']++;this[ns].setAttrs(config);}else{__cov_dDY1oPzWlroRs49oPPuh3Q.b['8'][1]++;}}else{__cov_dDY1oPzWlroRs49oPPuh3Q.b['7'][1]++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['20']++;this[ns]=new Plugin(config);__cov_dDY1oPzWlroRs49oPPuh3Q.s['21']++;this._plugins[ns]=Plugin;}}else{__cov_dDY1oPzWlroRs49oPPuh3Q.b['4'][1]++;}}__cov_dDY1oPzWlroRs49oPPuh3Q.s['22']++;return this;},unplug:function(plugin){__cov_dDY1oPzWlroRs49oPPuh3Q.f['4']++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['23']++;var ns=plugin,plugins=this._plugins;__cov_dDY1oPzWlroRs49oPPuh3Q.s['24']++;if(plugin){__cov_dDY1oPzWlroRs49oPPuh3Q.b['9'][0]++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['25']++;if(L.isFunction(plugin)){__cov_dDY1oPzWlroRs49oPPuh3Q.b['10'][0]++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['26']++;ns=plugin.NS;__cov_dDY1oPzWlroRs49oPPuh3Q.s['27']++;if((__cov_dDY1oPzWlroRs49oPPuh3Q.b['12'][0]++,ns)&&((__cov_dDY1oPzWlroRs49oPPuh3Q.b['12'][1]++,!plugins[ns])||(__cov_dDY1oPzWlroRs49oPPuh3Q.b['12'][2]++,plugins[ns]!==plugin))){__cov_dDY1oPzWlroRs49oPPuh3Q.b['11'][0]++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['28']++;ns=null;}else{__cov_dDY1oPzWlroRs49oPPuh3Q.b['11'][1]++;}}else{__cov_dDY1oPzWlroRs49oPPuh3Q.b['10'][1]++;}__cov_dDY1oPzWlroRs49oPPuh3Q.s['29']++;if(ns){__cov_dDY1oPzWlroRs49oPPuh3Q.b['13'][0]++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['30']++;if(this[ns]){__cov_dDY1oPzWlroRs49oPPuh3Q.b['14'][0]++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['31']++;if(this[ns].destroy){__cov_dDY1oPzWlroRs49oPPuh3Q.b['15'][0]++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['32']++;this[ns].destroy();}else{__cov_dDY1oPzWlroRs49oPPuh3Q.b['15'][1]++;}__cov_dDY1oPzWlroRs49oPPuh3Q.s['33']++;delete this[ns];}else{__cov_dDY1oPzWlroRs49oPPuh3Q.b['14'][1]++;}__cov_dDY1oPzWlroRs49oPPuh3Q.s['34']++;if(plugins[ns]){__cov_dDY1oPzWlroRs49oPPuh3Q.b['16'][0]++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['35']++;delete plugins[ns];}else{__cov_dDY1oPzWlroRs49oPPuh3Q.b['16'][1]++;}}else{__cov_dDY1oPzWlroRs49oPPuh3Q.b['13'][1]++;}}else{__cov_dDY1oPzWlroRs49oPPuh3Q.b['9'][1]++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['36']++;for(ns in this._plugins){__cov_dDY1oPzWlroRs49oPPuh3Q.s['37']++;if(this._plugins.hasOwnProperty(ns)){__cov_dDY1oPzWlroRs49oPPuh3Q.b['17'][0]++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['38']++;this.unplug(ns);}else{__cov_dDY1oPzWlroRs49oPPuh3Q.b['17'][1]++;}}}__cov_dDY1oPzWlroRs49oPPuh3Q.s['39']++;return this;},hasPlugin:function(ns){__cov_dDY1oPzWlroRs49oPPuh3Q.f['5']++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['40']++;return(__cov_dDY1oPzWlroRs49oPPuh3Q.b['18'][0]++,this._plugins[ns])&&(__cov_dDY1oPzWlroRs49oPPuh3Q.b['18'][1]++,this[ns]);},_initPlugins:function(config){__cov_dDY1oPzWlroRs49oPPuh3Q.f['6']++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['41']++;this._plugins=(__cov_dDY1oPzWlroRs49oPPuh3Q.b['19'][0]++,this._plugins)||(__cov_dDY1oPzWlroRs49oPPuh3Q.b['19'][1]++,{});__cov_dDY1oPzWlroRs49oPPuh3Q.s['42']++;if(this._initConfigPlugins){__cov_dDY1oPzWlroRs49oPPuh3Q.b['20'][0]++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['43']++;this._initConfigPlugins(config);}else{__cov_dDY1oPzWlroRs49oPPuh3Q.b['20'][1]++;}},_destroyPlugins:function(){__cov_dDY1oPzWlroRs49oPPuh3Q.f['7']++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['44']++;this.unplug();}};__cov_dDY1oPzWlroRs49oPPuh3Q.s['45']++;Y.namespace('Plugin').Host=PluginHost;},'@VERSION@',{'requires':['yui-base']});
+__cov_dDY1oPzWlroRs49oPPuh3Q.s['1']++;YUI.add('pluginhost-base',function(Y,NAME){__cov_dDY1oPzWlroRs49oPPuh3Q.f['1']++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['2']++;var L=Y.Lang;__cov_dDY1oPzWlroRs49oPPuh3Q.s['3']++;function PluginHost(){__cov_dDY1oPzWlroRs49oPPuh3Q.f['2']++;}__cov_dDY1oPzWlroRs49oPPuh3Q.s['4']++;PluginHost.prototype={plug:function(Plugin,config){__cov_dDY1oPzWlroRs49oPPuh3Q.f['3']++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['5']++;var i,ln,ns;__cov_dDY1oPzWlroRs49oPPuh3Q.s['6']++;this._plugins=(__cov_dDY1oPzWlroRs49oPPuh3Q.b['1'][0]++,this._plugins)||(__cov_dDY1oPzWlroRs49oPPuh3Q.b['1'][1]++,{});__cov_dDY1oPzWlroRs49oPPuh3Q.s['7']++;if(L.isArray(Plugin)){__cov_dDY1oPzWlroRs49oPPuh3Q.b['2'][0]++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['8']++;for(i=0,ln=Plugin.length;i<ln;i++){__cov_dDY1oPzWlroRs49oPPuh3Q.s['9']++;this.plug(Plugin[i]);}}else{__cov_dDY1oPzWlroRs49oPPuh3Q.b['2'][1]++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['10']++;if((__cov_dDY1oPzWlroRs49oPPuh3Q.b['4'][0]++,Plugin)&&(__cov_dDY1oPzWlroRs49oPPuh3Q.b['4'][1]++,!L.isFunction(Plugin))){__cov_dDY1oPzWlroRs49oPPuh3Q.b['3'][0]++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['11']++;config=Plugin.cfg;__cov_dDY1oPzWlroRs49oPPuh3Q.s['12']++;Plugin=Plugin.fn;}else{__cov_dDY1oPzWlroRs49oPPuh3Q.b['3'][1]++;}__cov_dDY1oPzWlroRs49oPPuh3Q.s['13']++;if((__cov_dDY1oPzWlroRs49oPPuh3Q.b['6'][0]++,Plugin)&&(__cov_dDY1oPzWlroRs49oPPuh3Q.b['6'][1]++,Plugin.NS)){__cov_dDY1oPzWlroRs49oPPuh3Q.b['5'][0]++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['14']++;ns=Plugin.NS;__cov_dDY1oPzWlroRs49oPPuh3Q.s['15']++;config=(__cov_dDY1oPzWlroRs49oPPuh3Q.b['7'][0]++,config)||(__cov_dDY1oPzWlroRs49oPPuh3Q.b['7'][1]++,{});__cov_dDY1oPzWlroRs49oPPuh3Q.s['16']++;config.host=this;__cov_dDY1oPzWlroRs49oPPuh3Q.s['17']++;if(this.hasPlugin(ns)){__cov_dDY1oPzWlroRs49oPPuh3Q.b['8'][0]++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['18']++;if(this[ns].setAttrs){__cov_dDY1oPzWlroRs49oPPuh3Q.b['9'][0]++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['19']++;this[ns].setAttrs(config);}else{__cov_dDY1oPzWlroRs49oPPuh3Q.b['9'][1]++;}}else{__cov_dDY1oPzWlroRs49oPPuh3Q.b['8'][1]++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['20']++;this[ns]=new Plugin(config);__cov_dDY1oPzWlroRs49oPPuh3Q.s['21']++;this._plugins[ns]=Plugin;}}else{__cov_dDY1oPzWlroRs49oPPuh3Q.b['5'][1]++;}}__cov_dDY1oPzWlroRs49oPPuh3Q.s['22']++;return this;},unplug:function(plugin){__cov_dDY1oPzWlroRs49oPPuh3Q.f['4']++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['23']++;var ns=plugin,plugins;__cov_dDY1oPzWlroRs49oPPuh3Q.s['24']++;this._plugins=(__cov_dDY1oPzWlroRs49oPPuh3Q.b['10'][0]++,this._plugins)||(__cov_dDY1oPzWlroRs49oPPuh3Q.b['10'][1]++,{});__cov_dDY1oPzWlroRs49oPPuh3Q.s['25']++;plugins=this._plugins;__cov_dDY1oPzWlroRs49oPPuh3Q.s['26']++;if(plugin){__cov_dDY1oPzWlroRs49oPPuh3Q.b['11'][0]++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['27']++;if(L.isFunction(plugin)){__cov_dDY1oPzWlroRs49oPPuh3Q.b['12'][0]++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['28']++;ns=plugin.NS;__cov_dDY1oPzWlroRs49oPPuh3Q.s['29']++;if((__cov_dDY1oPzWlroRs49oPPuh3Q.b['14'][0]++,ns)&&((__cov_dDY1oPzWlroRs49oPPuh3Q.b['14'][1]++,!plugins[ns])||(__cov_dDY1oPzWlroRs49oPPuh3Q.b['14'][2]++,plugins[ns]!==plugin))){__cov_dDY1oPzWlroRs49oPPuh3Q.b['13'][0]++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['30']++;ns=null;}else{__cov_dDY1oPzWlroRs49oPPuh3Q.b['13'][1]++;}}else{__cov_dDY1oPzWlroRs49oPPuh3Q.b['12'][1]++;}__cov_dDY1oPzWlroRs49oPPuh3Q.s['31']++;if(ns){__cov_dDY1oPzWlroRs49oPPuh3Q.b['15'][0]++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['32']++;if(this[ns]){__cov_dDY1oPzWlroRs49oPPuh3Q.b['16'][0]++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['33']++;if(this[ns].destroy){__cov_dDY1oPzWlroRs49oPPuh3Q.b['17'][0]++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['34']++;this[ns].destroy();}else{__cov_dDY1oPzWlroRs49oPPuh3Q.b['17'][1]++;}__cov_dDY1oPzWlroRs49oPPuh3Q.s['35']++;delete this[ns];}else{__cov_dDY1oPzWlroRs49oPPuh3Q.b['16'][1]++;}__cov_dDY1oPzWlroRs49oPPuh3Q.s['36']++;if(plugins[ns]){__cov_dDY1oPzWlroRs49oPPuh3Q.b['18'][0]++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['37']++;delete plugins[ns];}else{__cov_dDY1oPzWlroRs49oPPuh3Q.b['18'][1]++;}}else{__cov_dDY1oPzWlroRs49oPPuh3Q.b['15'][1]++;}}else{__cov_dDY1oPzWlroRs49oPPuh3Q.b['11'][1]++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['38']++;for(ns in this._plugins){__cov_dDY1oPzWlroRs49oPPuh3Q.s['39']++;if(this._plugins.hasOwnProperty(ns)){__cov_dDY1oPzWlroRs49oPPuh3Q.b['19'][0]++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['40']++;this.unplug(ns);}else{__cov_dDY1oPzWlroRs49oPPuh3Q.b['19'][1]++;}}}__cov_dDY1oPzWlroRs49oPPuh3Q.s['41']++;return this;},hasPlugin:function(ns){__cov_dDY1oPzWlroRs49oPPuh3Q.f['5']++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['42']++;return(__cov_dDY1oPzWlroRs49oPPuh3Q.b['20'][0]++,this._plugins)&&(__cov_dDY1oPzWlroRs49oPPuh3Q.b['20'][1]++,this._plugins[ns])&&(__cov_dDY1oPzWlroRs49oPPuh3Q.b['20'][2]++,this[ns]);},_initPlugins:function(config){__cov_dDY1oPzWlroRs49oPPuh3Q.f['6']++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['43']++;this._plugins=(__cov_dDY1oPzWlroRs49oPPuh3Q.b['21'][0]++,this._plugins)||(__cov_dDY1oPzWlroRs49oPPuh3Q.b['21'][1]++,{});__cov_dDY1oPzWlroRs49oPPuh3Q.s['44']++;if(this._initConfigPlugins){__cov_dDY1oPzWlroRs49oPPuh3Q.b['22'][0]++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['45']++;this._initConfigPlugins(config);}else{__cov_dDY1oPzWlroRs49oPPuh3Q.b['22'][1]++;}},_destroyPlugins:function(){__cov_dDY1oPzWlroRs49oPPuh3Q.f['7']++;__cov_dDY1oPzWlroRs49oPPuh3Q.s['46']++;this.unplug();}};__cov_dDY1oPzWlroRs49oPPuh3Q.s['47']++;Y.namespace('Plugin').Host=PluginHost;},'@VERSION@',{'requires':['yui-base']});
View
11 build/pluginhost-base/pluginhost-base-debug.js
@@ -36,7 +36,7 @@ YUI.add('pluginhost-base', function (Y, NAME) {
var L = Y.Lang;
function PluginHost() {
- this._plugins = {};
+ // do not initialize this._plugins, because Y.Node's may have been created before Y.PluginHost was loaded
}
PluginHost.prototype = {
@@ -61,6 +61,8 @@ YUI.add('pluginhost-base', function (Y, NAME) {
plug: function(Plugin, config) {
var i, ln, ns;
+ this._plugins = this._plugins || {};
+
if (L.isArray(Plugin)) {
for (i = 0, ln = Plugin.length; i < ln; i++) {
this.plug(Plugin[i]);
@@ -107,7 +109,10 @@ YUI.add('pluginhost-base', function (Y, NAME) {
*/
unplug: function(plugin) {
var ns = plugin,
- plugins = this._plugins;
+ plugins;
+
+ this._plugins = this._plugins || {};
+ plugins = this._plugins;
if (plugin) {
if (L.isFunction(plugin)) {
@@ -146,7 +151,7 @@ YUI.add('pluginhost-base', function (Y, NAME) {
* @return {Plugin} Returns a truthy value (the plugin instance) if present, or undefined if not.
*/
hasPlugin : function(ns) {
- return (this._plugins[ns] && this[ns]);
+ return (this._plugins && this._plugins[ns] && this[ns]);
},
/**
View
2  build/pluginhost-base/pluginhost-base-min.js
@@ -1 +1 @@
-YUI.add("pluginhost-base",function(e,t){function r(){this._plugins={}}var n=e.Lang;r.prototype={plug:function(e,t){var r,i,s;if(n.isArray(e))for(r=0,i=e.length;r<i;r++)this.plug(e[r]);else e&&!n.isFunction(e)&&(t=e.cfg,e=e.fn),e&&e.NS&&(s=e.NS,t=t||{},t.host=this,this.hasPlugin(s)?this[s].setAttrs&&this[s].setAttrs(t):(this[s]=new e(t),this._plugins[s]=e));return this},unplug:function(e){var t=e,r=this._plugins;if(e)n.isFunction(e)&&(t=e.NS,t&&(!r[t]||r[t]!==e)&&(t=null)),t&&(this[t]&&(this[t].destroy&&this[t].destroy(),delete this[t]),r[t]&&delete r[t]);else for(t in this._plugins)this._plugins.hasOwnProperty(t)&&this.unplug(t);return this},hasPlugin:function(e){return this._plugins[e]&&this[e]},_initPlugins:function(e){this._plugins=this._plugins||{},this._initConfigPlugins&&this._initConfigPlugins(e)},_destroyPlugins:function(){this.unplug()}},e.namespace("Plugin").Host=r},"@VERSION@",{requires:["yui-base"]});
+YUI.add("pluginhost-base",function(e,t){function r(){}var n=e.Lang;r.prototype={plug:function(e,t){var r,i,s;this._plugins=this._plugins||{};if(n.isArray(e))for(r=0,i=e.length;r<i;r++)this.plug(e[r]);else e&&!n.isFunction(e)&&(t=e.cfg,e=e.fn),e&&e.NS&&(s=e.NS,t=t||{},t.host=this,this.hasPlugin(s)?this[s].setAttrs&&this[s].setAttrs(t):(this[s]=new e(t),this._plugins[s]=e));return this},unplug:function(e){var t=e,r;this._plugins=this._plugins||{},r=this._plugins;if(e)n.isFunction(e)&&(t=e.NS,t&&(!r[t]||r[t]!==e)&&(t=null)),t&&(this[t]&&(this[t].destroy&&this[t].destroy(),delete this[t]),r[t]&&delete r[t]);else for(t in this._plugins)this._plugins.hasOwnProperty(t)&&this.unplug(t);return this},hasPlugin:function(e){return this._plugins&&this._plugins[e]&&this[e]},_initPlugins:function(e){this._plugins=this._plugins||{},this._initConfigPlugins&&this._initConfigPlugins(e)},_destroyPlugins:function(){this.unplug()}},e.namespace("Plugin").Host=r},"@VERSION@",{requires:["yui-base"]});
View
11 build/pluginhost-base/pluginhost-base.js
@@ -36,7 +36,7 @@ YUI.add('pluginhost-base', function (Y, NAME) {
var L = Y.Lang;
function PluginHost() {
- this._plugins = {};
+ // do not initialize this._plugins, because Y.Node's may have been created before Y.PluginHost was loaded
}
PluginHost.prototype = {
@@ -61,6 +61,8 @@ YUI.add('pluginhost-base', function (Y, NAME) {
plug: function(Plugin, config) {
var i, ln, ns;
+ this._plugins = this._plugins || {};
+
if (L.isArray(Plugin)) {
for (i = 0, ln = Plugin.length; i < ln; i++) {
this.plug(Plugin[i]);
@@ -105,7 +107,10 @@ YUI.add('pluginhost-base', function (Y, NAME) {
*/
unplug: function(plugin) {
var ns = plugin,
- plugins = this._plugins;
+ plugins;
+
+ this._plugins = this._plugins || {};
+ plugins = this._plugins;
if (plugin) {
if (L.isFunction(plugin)) {
@@ -144,7 +149,7 @@ YUI.add('pluginhost-base', function (Y, NAME) {
* @return {Plugin} Returns a truthy value (the plugin instance) if present, or undefined if not.
*/
hasPlugin : function(ns) {
- return (this._plugins[ns] && this[ns]);
+ return (this._plugins && this._plugins[ns] && this[ns]);
},
/**
View
6 src/event/tests/manual/mouseenter.html
@@ -186,7 +186,11 @@
document.getElementById('memsize').onclick = function () {
//memsnap();
//console.log(count);
- console.log(Y.Object.keys(Y.Node._instances).length);
+ if (Y.Node._instances) {
+ console.log(Y.Object.keys(Y.Node._instances).length);
+ } else {
+ console.log('Nothing to track, since Y.Node._instances is not used in this browser');
+ }
};
});
</script>
View
45 src/node/js/node-core.js
@@ -28,6 +28,8 @@ var DOT = '.',
UID = '_yuid',
EMPTY_OBJ = {},
+ use_instance_map = 0 < Y.UA.ie && Y.UA.ie < 10, // define flag, in case other browsers need it, too
+
_slice = Array.prototype.slice,
Y_DOM = Y.DOM,
@@ -46,7 +48,7 @@ var DOT = '.',
var uid = (node.nodeType !== 9) ? node.uniqueID : node[UID];
- if (uid && Y_Node._instances[uid] && Y_Node._instances[uid]._node !== node) {
+ if (use_instance_map && uid && Y_Node._instances[uid] && Y_Node._instances[uid]._node !== node) {
node[UID] = null; // unset existing uid to prevent collision (via clone or hack)
}
@@ -123,14 +125,17 @@ Y_Node.SHOW_TRANSITION = 'fadeIn';
Y_Node.HIDE_TRANSITION = 'fadeOut';
/**
- * A list of Node instances that have been created
+ * A list of Node instances that have been created. Only defined in browsers
+ * that already have broken GC, since this global map also breaks GC.
* @private
* @type Object
* @property _instances
* @static
*
*/
-Y_Node._instances = {};
+if (use_instance_map) {
+ Y_Node._instances = {};
+}
/**
* Retrieves the DOM node bound to a Node instance
@@ -287,13 +292,24 @@ Y_Node.one = function(node) {
}
if (node.nodeType || Y.DOM.isWindow(node)) { // avoid bad input (numbers, boolean, etc)
- uid = (node.uniqueID && node.nodeType !== 9) ? node.uniqueID : node._yuid;
- instance = Y_Node._instances[uid]; // reuse exising instances
+ if (use_instance_map) {
+ uid = (node.uniqueID && node.nodeType !== 9) ? node.uniqueID : node[UID];
+ instance = Y_Node._instances[uid]; // reuse exising instances
+ } else {
+ instance = node._yui_instances && node._yui_instances[Y._yuid]; // reuse exising instances
+ }
cachedNode = instance ? instance._node : null;
if (!instance || (cachedNode && node !== cachedNode)) { // new Node when nodes don't match
instance = new Y_Node(node);
- if (node.nodeType != 11) { // dont cache document fragment
- Y_Node._instances[instance[UID]] = instance; // cache node
+ if (node.nodeType != 11) { // don't cache document fragment
+ if (use_instance_map) {
+ Y_Node._instances[instance[UID]] = instance; // cache node
+ } else {
+ if (!node._yui_instances) {
+ node._yui_instances = {};
+ }
+ node._yui_instances[Y._yuid] = instance; // cache node
+ }
}
}
}
@@ -375,7 +391,6 @@ Y.mix(Y_Node.prototype, {
str += '.' + className.replace(' ', '.');
}
- // TODO: add yuid?
str += ' ' + this[UID];
}
return str;
@@ -745,7 +760,11 @@ Y.mix(Y_Node.prototype, {
if (recursive) {
Y.NodeList.each(this.all('*'), function(node) {
- instance = Y_Node._instances[node[UID]];
+ if (use_instance_map) {
+ instance = Y_Node._instances[node[UID]];
+ } else {
+ instance = node._yui_instances && node._yui_instances[Y._yuid];
+ }
if (instance) {
instance.destroy();
} else { // purge in case added by other means
@@ -754,10 +773,16 @@ Y.mix(Y_Node.prototype, {
});
}
+ if (this._node._yui_instances) {
+ delete this._node._yui_instances[Y._yuid];
+ }
+
this._node = null;
this._stateProxy = null;
- delete Y_Node._instances[this._yuid];
+ if (use_instance_map) {
+ delete Y_Node._instances[this[UID]];
+ }
},
/**
View
5 src/node/js/node-pluginhost.js
@@ -37,11 +37,6 @@ Y.Node.unplug = function() {
Y.mix(Y.Node, Y.Plugin.Host, false, null, 1);
-// run PluginHost constructor on cached Node instances
-Y.Object.each(Y.Node._instances, function (node) {
- Y.Plugin.Host.apply(node);
-});
-
// allow batching of plug/unplug via NodeList
// doesn't use NodeList.importMethod because we need real Nodes (not tmpNode)
/**
View
39 src/node/js/nodelist.js
@@ -75,11 +75,18 @@ NodeList.addMethod = function(name, fn, context) {
args = arguments;
Y.Array.each(this._nodes, function(node) {
- var UID = (node.uniqueID && node.nodeType !== 9 ) ? 'uniqueID' : '_yuid',
- instance = Y.Node._instances[node[UID]],
+ var uid,
+ instance,
ctx,
result;
+ if (Y.Node._instances) {
+ uid = (node.uniqueID && node.nodeType !== 9 ) ? node.uniqueID : node[UID];
+ instance = Y.Node._instances[uid];
+ } else {
+ instance = node._yui_instances && node._yui_instances[Y._yuid];
+ }
+
if (!instance) {
instance = NodeList._getTempNode(node);
}
@@ -168,7 +175,16 @@ Y.mix(NodeList.prototype, {
var nodelist = this;
Y.Array.each(this._nodes, function(node, index) {
- var instance = Y.Node._instances[node[UID]];
+ var uid,
+ instance;
+
+ if (Y.Node._instances) {
+ uid = (node.uniqueID && node.nodeType !== 9 ) ? node.uniqueID : node[UID];
+ instance = Y.Node._instances[uid];
+ } else {
+ instance = node._yui_instances && node._yui_instances[Y._yuid];
+ }
+
if (!instance) {
instance = NodeList._getTempNode(node);
}
@@ -406,11 +422,19 @@ NodeList.prototype.get = function(attr) {
nodes = this._nodes,
isNodeList = false,
getTemp = NodeList._getTempNode,
+ uid,
instance,
val;
if (nodes[0]) {
- instance = Y.Node._instances[nodes[0]._yuid] || getTemp(nodes[0]);
+ if (Y.Node._instances) {
+ uid = (nodes[0].uniqueID && nodes[0].nodeType !== 9 ) ? nodes[0].uniqueID : nodes[0][UID];
+ instance = Y.Node._instances[uid];
+ } else {
+ instance = nodes[0]._yui_instances && nodes[0]._yui_instances[Y._yuid];
+ }
+ instance = instance || getTemp(nodes[0]);
+
val = instance._get(attr);
if (val && val.nodeType) {
isNodeList = true;
@@ -418,7 +442,12 @@ NodeList.prototype.get = function(attr) {
}
Y.Array.each(nodes, function(node) {
- instance = Y.Node._instances[node._yuid];
+ if (Y.Node._instances) {
+ uid = (node.uniqueID && node.nodeType !== 9 ) ? node.uniqueID : node[UID];
+ instance = Y.Node._instances[uid];
+ } else {
+ instance = node._yui_instances && node._yui_instances[Y._yuid];
+ }
if (!instance) {
instance = getTemp(node);
View
6 src/node/tests/unit/assets/node-pluginhost-test.js
@@ -14,7 +14,7 @@ YUI.add('node-pluginhost-test', function(Y) {
delete this._Y;
},
- 'Loading node-pluginhost should update cached Node instances': function () {
+ 'Loading node-pluginhost should not update cached Node instances': function () {
var Y = this._Y,
someNode;
@@ -22,6 +22,10 @@ YUI.add('node-pluginhost-test', function(Y) {
someNode = Y.one('div');
Y.use('node-pluginhost');
+ Assert.isFalse(someNode.hasOwnProperty('_plugins'));
+
+ Y.use('shim-plugin');
+ someNode.plug(Y.Plugin.Shim);
Assert.isTrue(someNode.hasOwnProperty('_plugins'));
}
}));
View
12 src/node/tests/unit/node.html
@@ -226,7 +226,11 @@
'should cache node': function() {
var node = Y.Node.create('<div id="test-caching" />');
node.appendTo('body');
- Assert.areEqual(node, Y.Node._instances[node._yuid]);
+ if (Y.Node._instances) {
+ Assert.areEqual(node, Y.Node._instances[node._yuid]);
+ } else {
+ Assert.areEqual(node, Y.Node.getDOMNode(node)._yui_instances[Y._yuid]);
+ }
Assert.areEqual(Y.one('#test-caching'), node);
node.remove(true);
},
@@ -1761,7 +1765,11 @@
'should not cache document fragment': function() {
var node = Y.Node.create('<div>foo</div><div>bar</div>');
- Assert.isUndefined(Y.Node._instances[node._yuid]);
+ if (Y.Node._instances) {
+ Assert.isUndefined(Y.Node._instances[node._yuid]);
+ } else {
+ Assert.isUndefined(Y.Node.getDOMNode(node)._yui_instances);
+ }
},
'should return false if node is removed': function () {
View
11 src/pluginhost/js/PluginHost.js
@@ -34,7 +34,7 @@
var L = Y.Lang;
function PluginHost() {
- this._plugins = {};
+ // do not initialize this._plugins, because Y.Node's may have been created before Y.PluginHost was loaded
}
PluginHost.prototype = {
@@ -59,6 +59,8 @@
plug: function(Plugin, config) {
var i, ln, ns;
+ this._plugins = this._plugins || {};
+
if (L.isArray(Plugin)) {
for (i = 0, ln = Plugin.length; i < ln; i++) {
this.plug(Plugin[i]);
@@ -105,7 +107,10 @@
*/
unplug: function(plugin) {
var ns = plugin,
- plugins = this._plugins;
+ plugins;
+
+ this._plugins = this._plugins || {};
+ plugins = this._plugins;
if (plugin) {
if (L.isFunction(plugin)) {
@@ -144,7 +149,7 @@
* @return {Plugin} Returns a truthy value (the plugin instance) if present, or undefined if not.
*/
hasPlugin : function(ns) {
- return (this._plugins[ns] && this[ns]);
+ return (this._plugins && this._plugins[ns] && this[ns]);
},
/**
Something went wrong with that request. Please try again.