Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Change from using a WeakMap to use expando
Browse files Browse the repository at this point in the history
  • Loading branch information
arv committed Sep 11, 2013
1 parent 1a871e4 commit 1d32415
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
9 changes: 4 additions & 5 deletions src/ShadowRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@
var eventParentsTable = new WeakMap();
var insertionParentTable = new WeakMap();
var rendererForHostTable = new WeakMap();
var shadowDOMRendererTable = new WeakMap();

function distributeChildToInsertionPoint(child, insertionPoint) {
getDistributedChildNodes(insertionPoint).push(child);
Expand Down Expand Up @@ -554,7 +553,7 @@
},

associateNode: function(node) {
shadowDOMRendererTable.set(node, this);
node.impl.polymerShadowRenderer_ = this;
}
};

Expand Down Expand Up @@ -613,7 +612,7 @@
* This gets called when a node was added or removed to it.
*/
Node.prototype.invalidateShadowRenderer = function(force) {
var renderer = shadowDOMRendererTable.get(this);
var renderer = this.impl.polymerShadowRenderer_;
if (renderer) {
renderer.invalidate();
return true;
Expand All @@ -623,7 +622,7 @@
};

HTMLContentElement.prototype.getDistributedNodes = function() {
var renderer = shadowDOMRendererTable.get(this);
var renderer = this.impl.polymerShadowRenderer_;
if (renderer)
renderer.render();
return getDistributedChildNodes(this);
Expand All @@ -638,7 +637,7 @@
var renderer;
if (shadowRoot)
renderer = getRendererForShadowRoot(shadowRoot);
shadowDOMRendererTable.set(this, renderer);
this.impl.polymerShadowRenderer_ = renderer;
if (renderer)
renderer.invalidate();
};
Expand Down
6 changes: 2 additions & 4 deletions src/wrappers/Element.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@
var registerWrapper = scope.registerWrapper;
var wrappers = scope.wrappers;

var shadowRootTable = new WeakMap();
var OriginalElement = window.Element;


var matchesName = oneOf(OriginalElement.prototype, [
'matches',
'mozMatchesSelector',
Expand Down Expand Up @@ -47,7 +45,7 @@
mixin(Element.prototype, {
createShadowRoot: function() {
var newShadowRoot = new wrappers.ShadowRoot(this);
shadowRootTable.set(this, newShadowRoot);
this.impl.polymerShadowRoot_ = newShadowRoot;

var renderer = scope.getRendererForHost(this);
renderer.invalidate();
Expand All @@ -56,7 +54,7 @@
},

get shadowRoot() {
return shadowRootTable.get(this) || null;
return this.impl.polymerShadowRoot_ || null;
},

setAttribute: function(name, value) {
Expand Down

0 comments on commit 1d32415

Please sign in to comment.