Skip to content

Commit

Permalink
remove unused code; minor changes based on review.
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Orvell committed Dec 14, 2015
1 parent e3753db commit c3fbd10
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 67 deletions.
42 changes: 13 additions & 29 deletions src/lib/experimental/patch-dom.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@

methods: ['appendChild', 'insertBefore', 'removeChild', 'replaceChild',
'querySelector', 'querySelectorAll', 'getDestinationInsertionPoints',
'cloneNode', /*'importNode',*/ 'setAttribute', 'removeAttribute'],
'cloneNode', 'setAttribute', 'removeAttribute'],
// <content>: getDistributedNodes

accessors: ['parentNode', 'childNodes',
Expand Down Expand Up @@ -192,10 +192,6 @@
}
var info = {
get: function() {
//log && console.log(this, name);
if (window.nug) {
debugger;
}
return dom(this)[name];
},
configurable: true
Expand Down Expand Up @@ -243,6 +239,8 @@

Polymer.DomApi.patchImpl = patchImpl;

// NOTE: patch logical implementations here so we can use
// composed getters
Polymer.TreeApi.Logical.saveChildNodes = function(node) {
if (!this.hasChildNodes(node)) {
node.__firstChild = node.firstChild;
Expand Down Expand Up @@ -277,10 +275,6 @@

Polymer.TreeApi.Composed = {


ensureParentNodes: function(parent, children) {
},

hasParentNode: function(node) {
return Boolean(node.__composedParent !== undefined);
},
Expand All @@ -290,10 +284,7 @@
},

getChildNodes: function(node) {
// return node.__composedChildNodes ||
// (!node.__patched && TreeApi.arrayCopy(node.childNodes));
return (node.__composedChildNodes &&
TreeApi.arrayCopy(node.__composedChildNodes)) ||
return node.__composedChildNodes ||
(!node.__patched && TreeApi.arrayCopy(node.childNodes));
},

Expand Down Expand Up @@ -326,25 +317,25 @@
getNextSibling: function(node) {
// TODO(sorvell): linked list
var parent = this.getParentNode(node);
//if (parent.__patched) {
if (parent.__patched) {
var c$ = this.getChildNodes(parent);
var i = c$.indexOf(node);
return c$[i+1];
//} else if (!node.__patched) {
// return node.nextSibling;
//}
} else if (!node.__patched) {
return node.nextSibling;
}
},

getPreviousSibling: function(node) {
// TODO(sorvell): linked list
var parent = this.getParentNode(node);
//if (parent.__patched) {
if (parent.__patched) {
var c$ = this.getChildNodes(parent);
var i = c$.indexOf(node);
return c$[i-1];
//} else if (!node.__patched) {
// return node.previousSibling;
//}
} else if (!node.__patched) {
return node.previousSibling;
}
},

// composed tracking needs to reset composed children here in case
Expand Down Expand Up @@ -407,8 +398,8 @@
}
this._removeChild(parentNode, node);
if (currentParent === parentNode) {
// TODO(sorvell); abort if the composedParent is not expected...
if (!node.__patched && node.parentNode !== node.__composedParent) {
//console.warn('composedParent wrong for', node);
return;
}
return nativeRemoveChild.call(parentNode, node);
Expand Down Expand Up @@ -445,13 +436,6 @@

};

// TODO(sorvell): only necessary if we allow document.importNode to be patched.
// var nativeImportNode = document.importNode;
// Polymer.Base.instanceTemplate = function(template) {
// return nativeImportNode.call(document,
// template._content || template.content, true);
// }

// patch important nodes
if (window.document) {
Polymer.dom(document);
Expand Down
2 changes: 0 additions & 2 deletions src/mini/shady.html
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,6 @@
composed.splice(j, 0, n);
}
}
// ensure composed parent is set
TreeApi.Composed.ensureParentNodes(container, children);
},

_matchesContentSelect: function(node, contentElement) {
Expand Down
36 changes: 0 additions & 36 deletions test/smoke/patch/patch-dom.html
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,6 @@
s.id = 'light';
s.textContent = 'Light';
rere.appendChild(s);
// TODO(sorvell); patch
Polymer.dom(s);
assert.equal(rere.querySelector('#light'), s);
assert.equal(s.parentNode, rere);
Polymer.dom.flush();
Expand Down Expand Up @@ -298,35 +296,6 @@
assert.notOk(projected);
});

test('Polymer.dom event', function() {
var test = document.querySelector('x-test');
var rere = test.root.querySelector('x-rereproject');
var re = rere.root.querySelector('x-reproject');
var p = re.root.querySelector('x-project');
var eventHandled = 0;
test.addEventListener('test-event', function(e) {
eventHandled++;
assert.equal(Polymer.dom(e).rootTarget, p);
assert.equal(Polymer.dom(e).localTarget, test);
var path = Polymer.dom(e).path;
// path includes window only on more recent Shadow DOM implementations
// account for that here.
assert.ok(path.length >= 10);
assert.equal(path[0], p);
assert.equal(path[2], re);
assert.equal(path[4], rere);
assert.equal(path[6], test);
});

rere.addEventListener('test-event', function(e) {
eventHandled++;
assert.equal(Polymer.dom(e).localTarget, rere);
});

p.fire('test-event');
assert.equal(eventHandled, 2);
});

test('Polymer.dom.childNodes is an array', function() {
assert.isTrue(Array.isArray(Polymer.dom(document.body).childNodes));
});
Expand Down Expand Up @@ -395,17 +364,12 @@
testNoAttr();
// set / unset `test` attr and see if it distributes properly
child.setAttribute('test', '');
//d.distributeContent();
Polymer.dom.flush();
testWithAttr();
//
child.removeAttribute('test');
//d.distributeContent();
Polymer.dom.flush();
testNoAttr();
//
child.setAttribute('test', '');
//d.distributeContent();
Polymer.dom.flush();
testWithAttr();
});
Expand Down

0 comments on commit c3fbd10

Please sign in to comment.