Index: polymer_1.0.4/bower_components/webcomponentsjs/ShadowDOM.js |
diff --git a/polymer_0.5.4/bower_components/webcomponentsjs/ShadowDOM.js b/polymer_1.0.4/bower_components/webcomponentsjs/ShadowDOM.js |
similarity index 95% |
copy from polymer_0.5.4/bower_components/webcomponentsjs/ShadowDOM.js |
copy to polymer_1.0.4/bower_components/webcomponentsjs/ShadowDOM.js |
index f3b604c104798028b14096ffb32bc0ec51e43fa6..dc67ad93777369cd83fb5186f924d7761c387789 100644 |
--- a/polymer_0.5.4/bower_components/webcomponentsjs/ShadowDOM.js |
+++ b/polymer_1.0.4/bower_components/webcomponentsjs/ShadowDOM.js |
@@ -7,7 +7,7 @@ |
* Code distributed by Google as part of the polymer project is also |
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt |
*/ |
-// @version 0.5.4 |
+// @version 0.7.5 |
if (typeof WeakMap === "undefined") { |
(function() { |
var defineProperty = Object.defineProperty; |
@@ -113,13 +113,20 @@ window.ShadowDOMPolyfill = {}; |
defineProperty(object, name, nonEnumerableDataDescriptor); |
} |
getOwnPropertyNames(window); |
- function getWrapperConstructor(node) { |
+ function getWrapperConstructor(node, opt_instance) { |
var nativePrototype = node.__proto__ || Object.getPrototypeOf(node); |
+ if (isFirefox) { |
+ try { |
+ getOwnPropertyNames(nativePrototype); |
+ } catch (error) { |
+ nativePrototype = nativePrototype.__proto__; |
+ } |
+ } |
var wrapperConstructor = constructorTable.get(nativePrototype); |
if (wrapperConstructor) return wrapperConstructor; |
var parentWrapperConstructor = getWrapperConstructor(nativePrototype); |
var GeneratedWrapper = createWrapperConstructor(parentWrapperConstructor); |
- registerInternal(nativePrototype, GeneratedWrapper, node); |
+ registerInternal(nativePrototype, GeneratedWrapper, opt_instance); |
return GeneratedWrapper; |
} |
function addForwardingProperties(nativePrototype, wrapperPrototype) { |
@@ -139,7 +146,7 @@ window.ShadowDOMPolyfill = {}; |
return /^on[a-z]+$/.test(name); |
} |
function isIdentifierName(name) { |
- return /^\w[a-zA-Z_0-9]*$/.test(name); |
+ return /^[a-zA-Z_$][a-zA-Z_$0-9]*$/.test(name); |
} |
function getGetter(name) { |
return hasEval && isIdentifierName(name) ? new Function("return this.__impl4cf1e782hg__." + name) : function() { |
@@ -179,8 +186,10 @@ window.ShadowDOMPolyfill = {}; |
} |
var descriptor = getDescriptor(source, name); |
var getter, setter; |
- if (allowMethod && typeof descriptor.value === "function") { |
- target[name] = getMethod(name); |
+ if (typeof descriptor.value === "function") { |
+ if (allowMethod) { |
+ target[name] = getMethod(name); |
+ } |
continue; |
} |
var isEvent = isEventHandlerName(name); |
@@ -188,15 +197,19 @@ window.ShadowDOMPolyfill = {}; |
if (descriptor.writable || descriptor.set || isBrokenSafari) { |
if (isEvent) setter = scope.getEventHandlerSetter(name); else setter = getSetter(name); |
} |
+ var configurable = isBrokenSafari || descriptor.configurable; |
defineProperty(target, name, { |
get: getter, |
set: setter, |
- configurable: descriptor.configurable, |
+ configurable: configurable, |
enumerable: descriptor.enumerable |
}); |
} |
} |
function register(nativeConstructor, wrapperConstructor, opt_instance) { |
+ if (nativeConstructor == null) { |
+ return; |
+ } |
var nativePrototype = nativeConstructor.prototype; |
registerInternal(nativePrototype, wrapperConstructor, opt_instance); |
mixinStatics(wrapperConstructor, nativeConstructor); |
@@ -239,7 +252,11 @@ window.ShadowDOMPolyfill = {}; |
function wrap(impl) { |
if (impl === null) return null; |
assert(isNative(impl)); |
- return impl.__wrapper8e3dd93a60__ || (impl.__wrapper8e3dd93a60__ = new (getWrapperConstructor(impl))(impl)); |
+ var wrapper = impl.__wrapper8e3dd93a60__; |
+ if (wrapper != null) { |
+ return wrapper; |
+ } |
+ return impl.__wrapper8e3dd93a60__ = new (getWrapperConstructor(impl, impl))(impl); |
} |
function unwrap(wrapper) { |
if (wrapper === null) return null; |
@@ -294,6 +311,7 @@ window.ShadowDOMPolyfill = {}; |
scope.defineGetter = defineGetter; |
scope.defineWrapGetter = defineWrapGetter; |
scope.forwardMethodsToWrapper = forwardMethodsToWrapper; |
+ scope.isIdentifierName = isIdentifierName; |
scope.isWrapper = isWrapper; |
scope.isWrapperFor = isWrapperFor; |
scope.mixin = mixin; |
@@ -1723,6 +1741,7 @@ window.ShadowDOMPolyfill = {}; |
var OriginalDocumentFragment = window.DocumentFragment; |
var originalAppendChild = OriginalNode.prototype.appendChild; |
var originalCompareDocumentPosition = OriginalNode.prototype.compareDocumentPosition; |
+ var originalIsEqualNode = OriginalNode.prototype.isEqualNode; |
var originalInsertBefore = OriginalNode.prototype.insertBefore; |
var originalRemoveChild = OriginalNode.prototype.removeChild; |
var originalReplaceChild = OriginalNode.prototype.replaceChild; |
@@ -1951,6 +1970,9 @@ window.ShadowDOMPolyfill = {}; |
compareDocumentPosition: function(otherNode) { |
return originalCompareDocumentPosition.call(unsafeUnwrap(this), unwrapIfNeeded(otherNode)); |
}, |
+ isEqualNode: function(otherNode) { |
+ return originalIsEqualNode.call(unsafeUnwrap(this), unwrapIfNeeded(otherNode)); |
+ }, |
normalize: function() { |
var nodes = snapshotNodeList(this.childNodes); |
var remNodes = []; |
@@ -2028,7 +2050,10 @@ window.ShadowDOMPolyfill = {}; |
return index; |
} |
function shimSelector(selector) { |
- return String(selector).replace(/\/deep\//g, " "); |
+ return String(selector).replace(/\/deep\/|::shadow|>>>/g, " "); |
+ } |
+ function shimMatchesSelector(selector) { |
+ return String(selector).replace(/:host\(([^\s]+)\)/g, "$1").replace(/([^\s]):host/g, "$1").replace(":host", "*").replace(/\^|\/shadow\/|\/shadow-deep\/|::shadow|\/deep\/|::content|>>>/g, " "); |
} |
function findOne(node, selector) { |
var m, el = node.firstElementChild; |
@@ -2119,6 +2144,12 @@ window.ShadowDOMPolyfill = {}; |
return result; |
} |
}; |
+ var MatchesInterface = { |
+ matches: function(selector) { |
+ selector = shimMatchesSelector(selector); |
+ return scope.originalMatches.call(unsafeUnwrap(this), selector); |
+ } |
+ }; |
function getElementsByTagNameFiltered(p, index, result, localName, lowercase) { |
var target = unsafeUnwrap(this); |
var list; |
@@ -2173,6 +2204,7 @@ window.ShadowDOMPolyfill = {}; |
}; |
scope.GetElementsByInterface = GetElementsByInterface; |
scope.SelectorsInterface = SelectorsInterface; |
+ scope.MatchesInterface = MatchesInterface; |
})(window.ShadowDOMPolyfill); |
(function(scope) { |
@@ -2226,7 +2258,14 @@ window.ShadowDOMPolyfill = {}; |
return backwardsElement(this.previousSibling); |
} |
}; |
+ var NonElementParentNodeInterface = { |
+ getElementById: function(id) { |
+ if (/[ \t\n\r\f]/.test(id)) return null; |
+ return this.querySelector('[id="' + id + '"]'); |
+ } |
+ }; |
scope.ChildNodeInterface = ChildNodeInterface; |
+ scope.NonElementParentNodeInterface = NonElementParentNodeInterface; |
scope.ParentNodeInterface = ParentNodeInterface; |
})(window.ShadowDOMPolyfill); |
@@ -2244,6 +2283,12 @@ window.ShadowDOMPolyfill = {}; |
} |
CharacterData.prototype = Object.create(Node.prototype); |
mixin(CharacterData.prototype, { |
+ get nodeValue() { |
+ return this.data; |
+ }, |
+ set nodeValue(data) { |
+ this.data = data; |
+ }, |
get textContent() { |
return this.data; |
}, |
@@ -2299,6 +2344,10 @@ window.ShadowDOMPolyfill = {}; |
(function(scope) { |
"use strict"; |
+ if (!window.DOMTokenList) { |
+ console.warn("Missing DOMTokenList prototype, please include a " + "compatible classList polyfill such as http://goo.gl/uTcepH."); |
+ return; |
+ } |
var unsafeUnwrap = scope.unsafeUnwrap; |
var enqueueMutation = scope.enqueueMutation; |
function getClass(el) { |
@@ -2348,6 +2397,7 @@ window.ShadowDOMPolyfill = {}; |
var Node = scope.wrappers.Node; |
var ParentNodeInterface = scope.ParentNodeInterface; |
var SelectorsInterface = scope.SelectorsInterface; |
+ var MatchesInterface = scope.MatchesInterface; |
var addWrapNodeListMethod = scope.addWrapNodeListMethod; |
var enqueueMutation = scope.enqueueMutation; |
var mixin = scope.mixin; |
@@ -2402,13 +2452,11 @@ window.ShadowDOMPolyfill = {}; |
enqueAttributeChange(this, name, oldValue); |
invalidateRendererBasedOnAttribute(this, name); |
}, |
- matches: function(selector) { |
- return originalMatches.call(unsafeUnwrap(this), selector); |
- }, |
get classList() { |
var list = classListTable.get(this); |
if (!list) { |
list = unsafeUnwrap(this).classList; |
+ if (!list) return; |
list.ownerElement_ = this; |
classListTable.set(this, list); |
} |
@@ -2441,9 +2489,11 @@ window.ShadowDOMPolyfill = {}; |
mixin(Element.prototype, GetElementsByInterface); |
mixin(Element.prototype, ParentNodeInterface); |
mixin(Element.prototype, SelectorsInterface); |
+ mixin(Element.prototype, MatchesInterface); |
registerWrapper(OriginalElement, Element, document.createElementNS(null, "x")); |
scope.invalidateRendererBasedOnAttribute = invalidateRendererBasedOnAttribute; |
scope.matchesNames = matchesNames; |
+ scope.originalMatches = originalMatches; |
scope.wrappers.Element = Element; |
})(window.ShadowDOMPolyfill); |
@@ -2496,6 +2546,12 @@ window.ShadowDOMPolyfill = {}; |
} |
var voidElements = makeSet([ "area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr" ]); |
var plaintextParents = makeSet([ "style", "script", "xmp", "iframe", "noembed", "noframes", "plaintext", "noscript" ]); |
+ var XHTML_NS = "http://www.w3.org/1999/xhtml"; |
+ function needsSelfClosingSlash(node) { |
+ if (node.namespaceURI !== XHTML_NS) return true; |
+ var doctype = node.ownerDocument.doctype; |
+ return doctype && doctype.publicId && doctype.systemId; |
+ } |
function getOuterHTML(node, parentNode) { |
switch (node.nodeType) { |
case Node.ELEMENT_NODE: |
@@ -2505,9 +2561,11 @@ window.ShadowDOMPolyfill = {}; |
for (var i = 0, attr; attr = attrs[i]; i++) { |
s += " " + attr.name + '="' + escapeAttr(attr.value) + '"'; |
} |
- s += ">"; |
- if (voidElements[tagName]) return s; |
- return s + getInnerHTML(node) + "</" + tagName + ">"; |
+ if (voidElements[tagName]) { |
+ if (needsSelfClosingSlash(node)) s += "/"; |
+ return s + ">"; |
+ } |
+ return s + ">" + getInnerHTML(node) + "</" + tagName + ">"; |
case Node.TEXT_NODE: |
var data = node.data; |
@@ -3088,6 +3146,7 @@ window.ShadowDOMPolyfill = {}; |
var Element = scope.wrappers.Element; |
var HTMLElement = scope.wrappers.HTMLElement; |
var registerObject = scope.registerObject; |
+ var defineWrapGetter = scope.defineWrapGetter; |
var SVG_NS = "http://www.w3.org/2000/svg"; |
var svgTitleElement = document.createElementNS(SVG_NS, "title"); |
var SVGTitleElement = registerObject(svgTitleElement); |
@@ -3097,6 +3156,7 @@ window.ShadowDOMPolyfill = {}; |
Object.defineProperty(HTMLElement.prototype, "classList", descr); |
delete Element.prototype.classList; |
} |
+ defineWrapGetter(SVGElement, "ownerSVGElement"); |
scope.wrappers.SVGElement = SVGElement; |
})(window.ShadowDOMPolyfill); |
@@ -3240,30 +3300,128 @@ window.ShadowDOMPolyfill = {}; |
(function(scope) { |
"use strict"; |
+ var GetElementsByInterface = scope.GetElementsByInterface; |
+ var NonElementParentNodeInterface = scope.NonElementParentNodeInterface; |
+ var ParentNodeInterface = scope.ParentNodeInterface; |
+ var SelectorsInterface = scope.SelectorsInterface; |
+ var mixin = scope.mixin; |
+ var registerObject = scope.registerObject; |
+ var DocumentFragment = registerObject(document.createDocumentFragment()); |
+ mixin(DocumentFragment.prototype, ParentNodeInterface); |
+ mixin(DocumentFragment.prototype, SelectorsInterface); |
+ mixin(DocumentFragment.prototype, GetElementsByInterface); |
+ mixin(DocumentFragment.prototype, NonElementParentNodeInterface); |
+ var Comment = registerObject(document.createComment("")); |
+ scope.wrappers.Comment = Comment; |
+ scope.wrappers.DocumentFragment = DocumentFragment; |
+})(window.ShadowDOMPolyfill); |
+ |
+(function(scope) { |
+ "use strict"; |
+ var DocumentFragment = scope.wrappers.DocumentFragment; |
+ var TreeScope = scope.TreeScope; |
+ var elementFromPoint = scope.elementFromPoint; |
+ var getInnerHTML = scope.getInnerHTML; |
+ var getTreeScope = scope.getTreeScope; |
+ var mixin = scope.mixin; |
+ var rewrap = scope.rewrap; |
+ var setInnerHTML = scope.setInnerHTML; |
+ var unsafeUnwrap = scope.unsafeUnwrap; |
+ var unwrap = scope.unwrap; |
+ var shadowHostTable = new WeakMap(); |
+ var nextOlderShadowTreeTable = new WeakMap(); |
+ function ShadowRoot(hostWrapper) { |
+ var node = unwrap(unsafeUnwrap(hostWrapper).ownerDocument.createDocumentFragment()); |
+ DocumentFragment.call(this, node); |
+ rewrap(node, this); |
+ var oldShadowRoot = hostWrapper.shadowRoot; |
+ nextOlderShadowTreeTable.set(this, oldShadowRoot); |
+ this.treeScope_ = new TreeScope(this, getTreeScope(oldShadowRoot || hostWrapper)); |
+ shadowHostTable.set(this, hostWrapper); |
+ } |
+ ShadowRoot.prototype = Object.create(DocumentFragment.prototype); |
+ mixin(ShadowRoot.prototype, { |
+ constructor: ShadowRoot, |
+ get innerHTML() { |
+ return getInnerHTML(this); |
+ }, |
+ set innerHTML(value) { |
+ setInnerHTML(this, value); |
+ this.invalidateShadowRenderer(); |
+ }, |
+ get olderShadowRoot() { |
+ return nextOlderShadowTreeTable.get(this) || null; |
+ }, |
+ get host() { |
+ return shadowHostTable.get(this) || null; |
+ }, |
+ invalidateShadowRenderer: function() { |
+ return shadowHostTable.get(this).invalidateShadowRenderer(); |
+ }, |
+ elementFromPoint: function(x, y) { |
+ return elementFromPoint(this, this.ownerDocument, x, y); |
+ } |
+ }); |
+ scope.wrappers.ShadowRoot = ShadowRoot; |
+})(window.ShadowDOMPolyfill); |
+ |
+(function(scope) { |
+ "use strict"; |
var registerWrapper = scope.registerWrapper; |
var setWrapper = scope.setWrapper; |
var unsafeUnwrap = scope.unsafeUnwrap; |
var unwrap = scope.unwrap; |
var unwrapIfNeeded = scope.unwrapIfNeeded; |
var wrap = scope.wrap; |
+ var getTreeScope = scope.getTreeScope; |
var OriginalRange = window.Range; |
+ var ShadowRoot = scope.wrappers.ShadowRoot; |
+ function getHost(node) { |
+ var root = getTreeScope(node).root; |
+ if (root instanceof ShadowRoot) { |
+ return root.host; |
+ } |
+ return null; |
+ } |
+ function hostNodeToShadowNode(refNode, offset) { |
+ if (refNode.shadowRoot) { |
+ offset = Math.min(refNode.childNodes.length - 1, offset); |
+ var child = refNode.childNodes[offset]; |
+ if (child) { |
+ var insertionPoint = scope.getDestinationInsertionPoints(child); |
+ if (insertionPoint.length > 0) { |
+ var parentNode = insertionPoint[0].parentNode; |
+ if (parentNode.nodeType == Node.ELEMENT_NODE) { |
+ refNode = parentNode; |
+ } |
+ } |
+ } |
+ } |
+ return refNode; |
+ } |
+ function shadowNodeToHostNode(node) { |
+ node = wrap(node); |
+ return getHost(node) || node; |
+ } |
function Range(impl) { |
setWrapper(impl, this); |
} |
Range.prototype = { |
get startContainer() { |
- return wrap(unsafeUnwrap(this).startContainer); |
+ return shadowNodeToHostNode(unsafeUnwrap(this).startContainer); |
}, |
get endContainer() { |
- return wrap(unsafeUnwrap(this).endContainer); |
+ return shadowNodeToHostNode(unsafeUnwrap(this).endContainer); |
}, |
get commonAncestorContainer() { |
- return wrap(unsafeUnwrap(this).commonAncestorContainer); |
+ return shadowNodeToHostNode(unsafeUnwrap(this).commonAncestorContainer); |
}, |
setStart: function(refNode, offset) { |
+ refNode = hostNodeToShadowNode(refNode, offset); |
unsafeUnwrap(this).setStart(unwrapIfNeeded(refNode), offset); |
}, |
setEnd: function(refNode, offset) { |
+ refNode = hostNodeToShadowNode(refNode, offset); |
unsafeUnwrap(this).setEnd(unwrapIfNeeded(refNode), offset); |
}, |
setStartBefore: function(refNode) { |
@@ -3326,76 +3484,6 @@ window.ShadowDOMPolyfill = {}; |
(function(scope) { |
"use strict"; |
- var GetElementsByInterface = scope.GetElementsByInterface; |
- var ParentNodeInterface = scope.ParentNodeInterface; |
- var SelectorsInterface = scope.SelectorsInterface; |
- var mixin = scope.mixin; |
- var registerObject = scope.registerObject; |
- var DocumentFragment = registerObject(document.createDocumentFragment()); |
- mixin(DocumentFragment.prototype, ParentNodeInterface); |
- mixin(DocumentFragment.prototype, SelectorsInterface); |
- mixin(DocumentFragment.prototype, GetElementsByInterface); |
- var Comment = registerObject(document.createComment("")); |
- scope.wrappers.Comment = Comment; |
- scope.wrappers.DocumentFragment = DocumentFragment; |
-})(window.ShadowDOMPolyfill); |
- |
-(function(scope) { |
- "use strict"; |
- var DocumentFragment = scope.wrappers.DocumentFragment; |
- var TreeScope = scope.TreeScope; |
- var elementFromPoint = scope.elementFromPoint; |
- var getInnerHTML = scope.getInnerHTML; |
- var getTreeScope = scope.getTreeScope; |
- var mixin = scope.mixin; |
- var rewrap = scope.rewrap; |
- var setInnerHTML = scope.setInnerHTML; |
- var unsafeUnwrap = scope.unsafeUnwrap; |
- var unwrap = scope.unwrap; |
- var shadowHostTable = new WeakMap(); |
- var nextOlderShadowTreeTable = new WeakMap(); |
- var spaceCharRe = /[ \t\n\r\f]/; |
- function ShadowRoot(hostWrapper) { |
- var node = unwrap(unsafeUnwrap(hostWrapper).ownerDocument.createDocumentFragment()); |
- DocumentFragment.call(this, node); |
- rewrap(node, this); |
- var oldShadowRoot = hostWrapper.shadowRoot; |
- nextOlderShadowTreeTable.set(this, oldShadowRoot); |
- this.treeScope_ = new TreeScope(this, getTreeScope(oldShadowRoot || hostWrapper)); |
- shadowHostTable.set(this, hostWrapper); |
- } |
- ShadowRoot.prototype = Object.create(DocumentFragment.prototype); |
- mixin(ShadowRoot.prototype, { |
- constructor: ShadowRoot, |
- get innerHTML() { |
- return getInnerHTML(this); |
- }, |
- set innerHTML(value) { |
- setInnerHTML(this, value); |
- this.invalidateShadowRenderer(); |
- }, |
- get olderShadowRoot() { |
- return nextOlderShadowTreeTable.get(this) || null; |
- }, |
- get host() { |
- return shadowHostTable.get(this) || null; |
- }, |
- invalidateShadowRenderer: function() { |
- return shadowHostTable.get(this).invalidateShadowRenderer(); |
- }, |
- elementFromPoint: function(x, y) { |
- return elementFromPoint(this, this.ownerDocument, x, y); |
- }, |
- getElementById: function(id) { |
- if (spaceCharRe.test(id)) return null; |
- return this.querySelector('[id="' + id + '"]'); |
- } |
- }); |
- scope.wrappers.ShadowRoot = ShadowRoot; |
-})(window.ShadowDOMPolyfill); |
- |
-(function(scope) { |
- "use strict"; |
var Element = scope.wrappers.Element; |
var HTMLContentElement = scope.wrappers.HTMLContentElement; |
var HTMLShadowElement = scope.wrappers.HTMLShadowElement; |
@@ -3848,7 +3936,7 @@ window.ShadowDOMPolyfill = {}; |
return wrap(unsafeUnwrap(this).focusNode); |
}, |
addRange: function(range) { |
- unsafeUnwrap(this).addRange(unwrap(range)); |
+ unsafeUnwrap(this).addRange(unwrapIfNeeded(range)); |
}, |
collapse: function(node, index) { |
unsafeUnwrap(this).collapse(unwrapIfNeeded(node), index); |
@@ -3856,9 +3944,6 @@ window.ShadowDOMPolyfill = {}; |
containsNode: function(node, allowPartial) { |
return unsafeUnwrap(this).containsNode(unwrapIfNeeded(node), allowPartial); |
}, |
- extend: function(node, offset) { |
- unsafeUnwrap(this).extend(unwrapIfNeeded(node), offset); |
- }, |
getRangeAt: function(index) { |
return wrap(unsafeUnwrap(this).getRangeAt(index)); |
}, |
@@ -3872,15 +3957,68 @@ window.ShadowDOMPolyfill = {}; |
return unsafeUnwrap(this).toString(); |
} |
}; |
+ if (OriginalSelection.prototype.extend) { |
+ Selection.prototype.extend = function(node, offset) { |
+ unsafeUnwrap(this).extend(unwrapIfNeeded(node), offset); |
+ }; |
+ } |
registerWrapper(window.Selection, Selection, window.getSelection()); |
scope.wrappers.Selection = Selection; |
})(window.ShadowDOMPolyfill); |
(function(scope) { |
"use strict"; |
+ var registerWrapper = scope.registerWrapper; |
+ var setWrapper = scope.setWrapper; |
+ var unsafeUnwrap = scope.unsafeUnwrap; |
+ var unwrapIfNeeded = scope.unwrapIfNeeded; |
+ var wrap = scope.wrap; |
+ var OriginalTreeWalker = window.TreeWalker; |
+ function TreeWalker(impl) { |
+ setWrapper(impl, this); |
+ } |
+ TreeWalker.prototype = { |
+ get root() { |
+ return wrap(unsafeUnwrap(this).root); |
+ }, |
+ get currentNode() { |
+ return wrap(unsafeUnwrap(this).currentNode); |
+ }, |
+ set currentNode(node) { |
+ unsafeUnwrap(this).currentNode = unwrapIfNeeded(node); |
+ }, |
+ get filter() { |
+ return unsafeUnwrap(this).filter; |
+ }, |
+ parentNode: function() { |
+ return wrap(unsafeUnwrap(this).parentNode()); |
+ }, |
+ firstChild: function() { |
+ return wrap(unsafeUnwrap(this).firstChild()); |
+ }, |
+ lastChild: function() { |
+ return wrap(unsafeUnwrap(this).lastChild()); |
+ }, |
+ previousSibling: function() { |
+ return wrap(unsafeUnwrap(this).previousSibling()); |
+ }, |
+ previousNode: function() { |
+ return wrap(unsafeUnwrap(this).previousNode()); |
+ }, |
+ nextNode: function() { |
+ return wrap(unsafeUnwrap(this).nextNode()); |
+ } |
+ }; |
+ registerWrapper(OriginalTreeWalker, TreeWalker); |
+ scope.wrappers.TreeWalker = TreeWalker; |
+})(window.ShadowDOMPolyfill); |
+ |
+(function(scope) { |
+ "use strict"; |
var GetElementsByInterface = scope.GetElementsByInterface; |
var Node = scope.wrappers.Node; |
var ParentNodeInterface = scope.ParentNodeInterface; |
+ var NonElementParentNodeInterface = scope.NonElementParentNodeInterface; |
var Selection = scope.wrappers.Selection; |
var SelectorsInterface = scope.SelectorsInterface; |
var ShadowRoot = scope.wrappers.ShadowRoot; |
@@ -3915,7 +4053,7 @@ window.ShadowDOMPolyfill = {}; |
return wrap(original.apply(unsafeUnwrap(this), arguments)); |
}; |
} |
- [ "createComment", "createDocumentFragment", "createElement", "createElementNS", "createEvent", "createEventNS", "createRange", "createTextNode", "getElementById" ].forEach(wrapMethod); |
+ [ "createComment", "createDocumentFragment", "createElement", "createElementNS", "createEvent", "createEventNS", "createRange", "createTextNode" ].forEach(wrapMethod); |
var originalAdoptNode = document.adoptNode; |
function adoptNodeNoRemove(node, doc) { |
originalAdoptNode.call(unsafeUnwrap(doc), unwrap(node)); |
@@ -3953,6 +4091,25 @@ window.ShadowDOMPolyfill = {}; |
return SelectorsInterface.querySelectorAll.call(this, "[name=" + JSON.stringify(String(name)) + "]"); |
} |
}); |
+ var originalCreateTreeWalker = document.createTreeWalker; |
+ var TreeWalkerWrapper = scope.wrappers.TreeWalker; |
+ Document.prototype.createTreeWalker = function(root, whatToShow, filter, expandEntityReferences) { |
+ var newFilter = null; |
+ if (filter) { |
+ if (filter.acceptNode && typeof filter.acceptNode === "function") { |
+ newFilter = { |
+ acceptNode: function(node) { |
+ return filter.acceptNode(wrap(node)); |
+ } |
+ }; |
+ } else if (typeof filter === "function") { |
+ newFilter = function(node) { |
+ return filter(wrap(node)); |
+ }; |
+ } |
+ } |
+ return new TreeWalkerWrapper(originalCreateTreeWalker.call(unwrap(this), unwrap(root), whatToShow, newFilter, expandEntityReferences)); |
+ }; |
if (document.registerElement) { |
var originalRegisterElement = document.registerElement; |
Document.prototype.registerElement = function(tagName, object) { |
@@ -4016,10 +4173,11 @@ window.ShadowDOMPolyfill = {}; |
} |
forwardMethodsToWrapper([ window.HTMLBodyElement, window.HTMLDocument || window.Document, window.HTMLHeadElement, window.HTMLHtmlElement ], [ "appendChild", "compareDocumentPosition", "contains", "getElementsByClassName", "getElementsByTagName", "getElementsByTagNameNS", "insertBefore", "querySelector", "querySelectorAll", "removeChild", "replaceChild" ]); |
forwardMethodsToWrapper([ window.HTMLBodyElement, window.HTMLHeadElement, window.HTMLHtmlElement ], matchesNames); |
- forwardMethodsToWrapper([ window.HTMLDocument || window.Document ], [ "adoptNode", "importNode", "contains", "createComment", "createDocumentFragment", "createElement", "createElementNS", "createEvent", "createEventNS", "createRange", "createTextNode", "elementFromPoint", "getElementById", "getElementsByName", "getSelection" ]); |
+ forwardMethodsToWrapper([ window.HTMLDocument || window.Document ], [ "adoptNode", "importNode", "contains", "createComment", "createDocumentFragment", "createElement", "createElementNS", "createEvent", "createEventNS", "createRange", "createTextNode", "createTreeWalker", "elementFromPoint", "getElementById", "getElementsByName", "getSelection" ]); |
mixin(Document.prototype, GetElementsByInterface); |
mixin(Document.prototype, ParentNodeInterface); |
mixin(Document.prototype, SelectorsInterface); |
+ mixin(Document.prototype, NonElementParentNodeInterface); |
mixin(Document.prototype, { |
get implementation() { |
var implementation = implementationTable.get(this); |
@@ -4038,6 +4196,11 @@ window.ShadowDOMPolyfill = {}; |
function DOMImplementation(impl) { |
setWrapper(impl, this); |
} |
+ var originalCreateDocument = document.implementation.createDocument; |
+ DOMImplementation.prototype.createDocument = function() { |
+ arguments[2] = unwrap(arguments[2]); |
+ return wrap(originalCreateDocument.apply(unsafeUnwrap(this), arguments)); |
+ }; |
function wrapImplMethod(constructor, name) { |
var original = document.implementation[name]; |
constructor.prototype[name] = function() { |
@@ -4051,11 +4214,10 @@ window.ShadowDOMPolyfill = {}; |
}; |
} |
wrapImplMethod(DOMImplementation, "createDocumentType"); |
- wrapImplMethod(DOMImplementation, "createDocument"); |
wrapImplMethod(DOMImplementation, "createHTMLDocument"); |
forwardImplMethod(DOMImplementation, "hasFeature"); |
registerWrapper(window.DOMImplementation, DOMImplementation); |
- forwardMethodsToWrapper([ window.DOMImplementation ], [ "createDocumentType", "createDocument", "createHTMLDocument", "hasFeature" ]); |
+ forwardMethodsToWrapper([ window.DOMImplementation ], [ "createDocument", "createDocumentType", "createHTMLDocument", "hasFeature" ]); |
scope.adoptNodeNoRemove = adoptNodeNoRemove; |
scope.wrappers.DOMImplementation = DOMImplementation; |
scope.wrappers.Document = Document; |