remove unused code; minor changes based on review.

This commit is contained in:
Steven Orvell 2015-12-14 11:41:25 -08:00
parent e3753dbaeb
commit c3fbd10da8
3 changed files with 13 additions and 67 deletions

View File

@ -123,7 +123,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
methods: ['appendChild', 'insertBefore', 'removeChild', 'replaceChild',
'querySelector', 'querySelectorAll', 'getDestinationInsertionPoints',
'cloneNode', /*'importNode',*/ 'setAttribute', 'removeAttribute'],
'cloneNode', 'setAttribute', 'removeAttribute'],
// <content>: getDistributedNodes
accessors: ['parentNode', 'childNodes',
@ -192,10 +192,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
}
var info = {
get: function() {
//log && console.log(this, name);
if (window.nug) {
debugger;
}
return dom(this)[name];
},
configurable: true
@ -243,6 +239,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
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;
@ -277,10 +275,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
Polymer.TreeApi.Composed = {
ensureParentNodes: function(parent, children) {
},
hasParentNode: function(node) {
return Boolean(node.__composedParent !== undefined);
},
@ -290,10 +284,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
},
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));
},
@ -326,25 +317,25 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
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
@ -407,8 +398,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
}
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);
@ -445,13 +436,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
};
// 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);

View File

@ -353,8 +353,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
composed.splice(j, 0, n);
}
}
// ensure composed parent is set
TreeApi.Composed.ensureParentNodes(container, children);
},
_matchesContentSelect: function(node, contentElement) {

View File

@ -247,8 +247,6 @@ suite('Polymer.dom (patch)', function() {
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();
@ -298,35 +296,6 @@ suite('Polymer.dom (patch)', function() {
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));
});
@ -395,17 +364,12 @@ suite('Polymer.dom non-distributed elements', function() {
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();
});