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

Commit

Permalink
Replace SideTable with WeakMap
Browse files Browse the repository at this point in the history
  • Loading branch information
arv committed Sep 11, 2013
1 parent 13d542f commit 852721f
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 67 deletions.
2 changes: 1 addition & 1 deletion build.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
"../observe-js/src/observe.js",
"src/sidetable.js",
"../WeakMap/weakmap.js",
"src/wrappers.js",
"src/wrappers/events.js",
"src/wrappers/NodeList.js",
Expand Down
1 change: 1 addition & 0 deletions conf/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = function(karma) {
// list of files / patterns to load in the browser
files: [
'observe-js/src/observe.js',
'WeakMap/weakmap.js',
'ShadowDOM/tools/test/mocha-htmltest.js',
'ShadowDOM/conf/mocha.conf.js',
'ShadowDOM/node_modules/chai/chai.js',
Expand Down
2 changes: 1 addition & 1 deletion shadowdom.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

[
'../observe-js/src/observe.js',
'src/sidetable.js',
'../WeakMap/weakmap.js',
'src/wrappers.js',
'src/wrappers/events.js',
'src/wrappers/NodeList.js',
Expand Down
12 changes: 6 additions & 6 deletions src/ShadowRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@
parentNode.removeChild(node);
}

var distributedChildNodesTable = new SideTable();
var eventParentsTable = new SideTable();
var insertionParentTable = new SideTable();
var rendererForHostTable = new SideTable();
var shadowDOMRendererTable = new SideTable();
var distributedChildNodesTable = new WeakMap();
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 @@ -283,7 +283,7 @@
var newChildren = this.childNodes;
// plain array of real nodes.
var oldChildren = getChildNodesSnapshot(unwrap(nodeWrapper));
var added = opt_added || new SideTable();
var added = opt_added || new WeakMap();

var splices = spliceDiff.calculateSplices(newChildren, oldChildren);

Expand Down
40 changes: 0 additions & 40 deletions src/sidetable.js

This file was deleted.

4 changes: 2 additions & 2 deletions src/wrappers.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ var ShadowDOMPolyfill = {};
(function(scope) {
'use strict';

var constructorTable = new SideTable();
var nativePrototypeTable = new SideTable();
var constructorTable = new WeakMap();
var nativePrototypeTable = new WeakMap();
var wrappers = Object.create(null);

// Don't test for eval if document has CSP securityPolicy object and we can
Expand Down
2 changes: 1 addition & 1 deletion src/wrappers/Document.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
var wrapEventTargetMethods = scope.wrapEventTargetMethods;
var wrapNodeList = scope.wrapNodeList;

var implementationTable = new SideTable();
var implementationTable = new WeakMap();

function Document(node) {
Node.call(this, node);
Expand Down
2 changes: 1 addition & 1 deletion src/wrappers/Element.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
var registerWrapper = scope.registerWrapper;
var wrappers = scope.wrappers;

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


Expand Down
4 changes: 2 additions & 2 deletions src/wrappers/HTMLTemplateElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
var unwrap = scope.unwrap;
var wrap = scope.wrap;

var contentTable = new SideTable();
var templateContentsOwnerTable = new SideTable();
var contentTable = new WeakMap();
var templateContentsOwnerTable = new WeakMap();

// http://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/templates/index.html#dfn-template-contents-owner
function getTemplateContentsOwner(doc) {
Expand Down
4 changes: 2 additions & 2 deletions src/wrappers/ShadowRoot.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
var setInnerHTML = scope.setInnerHTML;
var unwrap = scope.unwrap;

var shadowHostTable = new SideTable();
var nextOlderShadowTreeTable = new SideTable();
var shadowHostTable = new WeakMap();
var nextOlderShadowTreeTable = new WeakMap();

function ShadowRoot(hostWrapper) {
var node = unwrap(hostWrapper.impl.ownerDocument.createDocumentFragment());
Expand Down
22 changes: 11 additions & 11 deletions src/wrappers/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
var wrap = scope.wrap;
var wrappers = scope.wrappers;

var wrappedFuns = new SideTable();
var listenersTable = new SideTable();
var handledEventsTable = new SideTable();
var targetTable = new SideTable();
var currentTargetTable = new SideTable();
var relatedTargetTable = new SideTable();
var eventPhaseTable = new SideTable();
var stopPropagationTable = new SideTable();
var stopImmediatePropagationTable = new SideTable();
var eventHandlersTable = new SideTable();
var eventPathTable = new SideTable();
var wrappedFuns = new WeakMap();
var listenersTable = new WeakMap();
var handledEventsTable = new WeakMap();
var targetTable = new WeakMap();
var currentTargetTable = new WeakMap();
var relatedTargetTable = new WeakMap();
var eventPhaseTable = new WeakMap();
var stopPropagationTable = new WeakMap();
var stopImmediatePropagationTable = new WeakMap();
var eventHandlersTable = new WeakMap();
var eventPathTable = new WeakMap();

function isShadowRoot(node) {
return node instanceof wrappers.ShadowRoot;
Expand Down

0 comments on commit 852721f

Please sign in to comment.