Index: third_party/polymer/components/webcomponentsjs/ShadowDOM.js |
diff --git a/third_party/polymer/components/webcomponentsjs/ShadowDOM.js b/third_party/polymer/components/webcomponentsjs/ShadowDOM.js |
index 5a59b4da12be1c9e686ce2cfa0e2805aa799cb44..96647356a0011c94a25d1612626df6a96698758b 100644 |
--- a/third_party/polymer/components/webcomponentsjs/ShadowDOM.js |
+++ b/third_party/polymer/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.7.22 |
+// @version 0.6.1 |
if (typeof WeakMap === "undefined") { |
(function() { |
var defineProperty = Object.defineProperty; |
@@ -113,7 +113,7 @@ window.ShadowDOMPolyfill = {}; |
defineProperty(object, name, nonEnumerableDataDescriptor); |
} |
getOwnPropertyNames(window); |
- function getWrapperConstructor(node, opt_instance) { |
+ function getWrapperConstructor(node) { |
var nativePrototype = node.__proto__ || Object.getPrototypeOf(node); |
if (isFirefox) { |
try { |
@@ -126,7 +126,7 @@ window.ShadowDOMPolyfill = {}; |
if (wrapperConstructor) return wrapperConstructor; |
var parentWrapperConstructor = getWrapperConstructor(nativePrototype); |
var GeneratedWrapper = createWrapperConstructor(parentWrapperConstructor); |
- registerInternal(nativePrototype, GeneratedWrapper, opt_instance); |
+ registerInternal(nativePrototype, GeneratedWrapper, node); |
return GeneratedWrapper; |
} |
function addForwardingProperties(nativePrototype, wrapperPrototype) { |
@@ -186,10 +186,8 @@ window.ShadowDOMPolyfill = {}; |
} |
var descriptor = getDescriptor(source, name); |
var getter, setter; |
- if (typeof descriptor.value === "function") { |
- if (allowMethod) { |
- target[name] = getMethod(name); |
- } |
+ if (allowMethod && typeof descriptor.value === "function") { |
+ target[name] = getMethod(name); |
continue; |
} |
var isEvent = isEventHandlerName(name); |
@@ -207,9 +205,6 @@ window.ShadowDOMPolyfill = {}; |
} |
} |
function register(nativeConstructor, wrapperConstructor, opt_instance) { |
- if (nativeConstructor == null) { |
- return; |
- } |
var nativePrototype = nativeConstructor.prototype; |
registerInternal(nativePrototype, wrapperConstructor, opt_instance); |
mixinStatics(wrapperConstructor, nativeConstructor); |
@@ -252,11 +247,7 @@ window.ShadowDOMPolyfill = {}; |
function wrap(impl) { |
if (impl === null) return null; |
assert(isNative(impl)); |
- var wrapper = impl.__wrapper8e3dd93a60__; |
- if (wrapper != null) { |
- return wrapper; |
- } |
- return impl.__wrapper8e3dd93a60__ = new (getWrapperConstructor(impl, impl))(impl); |
+ return impl.__wrapper8e3dd93a60__ || (impl.__wrapper8e3dd93a60__ = new (getWrapperConstructor(impl))(impl)); |
} |
function unwrap(wrapper) { |
if (wrapper === null) return null; |
@@ -306,7 +297,6 @@ window.ShadowDOMPolyfill = {}; |
}); |
}); |
} |
- scope.addForwardingProperties = addForwardingProperties; |
scope.assert = assert; |
scope.constructorTable = constructorTable; |
scope.defineGetter = defineGetter; |
@@ -1119,24 +1109,6 @@ window.ShadowDOMPolyfill = {}; |
stopImmediatePropagationTable.set(this, true); |
} |
}; |
- var supportsDefaultPrevented = function() { |
- var e = document.createEvent("Event"); |
- e.initEvent("test", true, true); |
- e.preventDefault(); |
- return e.defaultPrevented; |
- }(); |
- if (!supportsDefaultPrevented) { |
- Event.prototype.preventDefault = function() { |
- if (!this.cancelable) return; |
- unsafeUnwrap(this).preventDefault(); |
- Object.defineProperty(this, "defaultPrevented", { |
- get: function() { |
- return true; |
- }, |
- configurable: true |
- }); |
- }; |
- } |
registerWrapper(OriginalEvent, Event, document.createEvent("Event")); |
function unwrapOptions(options) { |
if (!options || !options.relatedTarget) return options; |
@@ -1764,8 +1736,8 @@ window.ShadowDOMPolyfill = {}; |
var originalInsertBefore = OriginalNode.prototype.insertBefore; |
var originalRemoveChild = OriginalNode.prototype.removeChild; |
var originalReplaceChild = OriginalNode.prototype.replaceChild; |
- var isIEOrEdge = /Trident|Edge/.test(navigator.userAgent); |
- var removeChildOriginalHelper = isIEOrEdge ? function(parent, child) { |
+ var isIe = /Trident|Edge/.test(navigator.userAgent); |
+ var removeChildOriginalHelper = isIe ? function(parent, child) { |
try { |
originalRemoveChild.call(parent, child); |
} catch (ex) { |
@@ -2277,14 +2249,7 @@ 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); |
@@ -2565,12 +2530,6 @@ 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: |
@@ -2580,11 +2539,9 @@ window.ShadowDOMPolyfill = {}; |
for (var i = 0, attr; attr = attrs[i]; i++) { |
s += " " + attr.name + '="' + escapeAttr(attr.value) + '"'; |
} |
- if (voidElements[tagName]) { |
- if (needsSelfClosingSlash(node)) s += "/"; |
- return s + ">"; |
- } |
- return s + ">" + getInnerHTML(node) + "</" + tagName + ">"; |
+ s += ">"; |
+ if (voidElements[tagName]) return s; |
+ return s + getInnerHTML(node) + "</" + tagName + ">"; |
case Node.TEXT_NODE: |
var data = node.data; |
@@ -2742,7 +2699,7 @@ window.ShadowDOMPolyfill = {}; |
enumerable: true |
}); |
} |
- [ "focus", "getBoundingClientRect", "getClientRects", "scrollIntoView" ].forEach(methodRequiresRendering); |
+ [ "getBoundingClientRect", "getClientRects", "scrollIntoView" ].forEach(methodRequiresRendering); |
registerWrapper(OriginalHTMLElement, HTMLElement, document.createElement("b")); |
scope.wrappers.HTMLElement = HTMLElement; |
scope.getInnerHTML = getInnerHTML; |
@@ -3164,29 +3121,18 @@ window.ShadowDOMPolyfill = {}; |
"use strict"; |
var Element = scope.wrappers.Element; |
var HTMLElement = scope.wrappers.HTMLElement; |
- var registerWrapper = scope.registerWrapper; |
+ var registerObject = scope.registerObject; |
var defineWrapGetter = scope.defineWrapGetter; |
- var unsafeUnwrap = scope.unsafeUnwrap; |
- var wrap = scope.wrap; |
- var mixin = scope.mixin; |
var SVG_NS = "http://www.w3.org/2000/svg"; |
- var OriginalSVGElement = window.SVGElement; |
var svgTitleElement = document.createElementNS(SVG_NS, "title"); |
+ var SVGTitleElement = registerObject(svgTitleElement); |
+ var SVGElement = Object.getPrototypeOf(SVGTitleElement.prototype).constructor; |
if (!("classList" in svgTitleElement)) { |
var descr = Object.getOwnPropertyDescriptor(Element.prototype, "classList"); |
Object.defineProperty(HTMLElement.prototype, "classList", descr); |
delete Element.prototype.classList; |
} |
- function SVGElement(node) { |
- Element.call(this, node); |
- } |
- SVGElement.prototype = Object.create(Element.prototype); |
- mixin(SVGElement.prototype, { |
- get ownerSVGElement() { |
- return wrap(unsafeUnwrap(this).ownerSVGElement); |
- } |
- }); |
- registerWrapper(OriginalSVGElement, SVGElement, document.createElementNS(SVG_NS, "title")); |
+ defineWrapGetter(SVGElement, "ownerSVGElement"); |
scope.wrappers.SVGElement = SVGElement; |
})(window.ShadowDOMPolyfill); |
@@ -3296,7 +3242,6 @@ window.ShadowDOMPolyfill = {}; |
(function(scope) { |
"use strict"; |
- var addForwardingProperties = scope.addForwardingProperties; |
var mixin = scope.mixin; |
var registerWrapper = scope.registerWrapper; |
var setWrapper = scope.setWrapper; |
@@ -3321,10 +3266,6 @@ window.ShadowDOMPolyfill = {}; |
unsafeUnwrap(this).texSubImage2D.apply(unsafeUnwrap(this), arguments); |
} |
}); |
- var OriginalWebGLRenderingContextBase = Object.getPrototypeOf(OriginalWebGLRenderingContext.prototype); |
- if (OriginalWebGLRenderingContextBase !== Object.prototype) { |
- addForwardingProperties(OriginalWebGLRenderingContextBase, WebGLRenderingContext.prototype); |
- } |
var instanceProperties = /WebKit/.test(navigator.userAgent) ? { |
drawingBufferHeight: null, |
drawingBufferWidth: null |
@@ -3335,27 +3276,18 @@ window.ShadowDOMPolyfill = {}; |
(function(scope) { |
"use strict"; |
- var Node = scope.wrappers.Node; |
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 registerWrapper = scope.registerWrapper; |
- var OriginalDocumentFragment = window.DocumentFragment; |
- function DocumentFragment(node) { |
- Node.call(this, node); |
- } |
- DocumentFragment.prototype = Object.create(Node.prototype); |
+ var DocumentFragment = registerObject(document.createDocumentFragment()); |
mixin(DocumentFragment.prototype, ParentNodeInterface); |
mixin(DocumentFragment.prototype, SelectorsInterface); |
mixin(DocumentFragment.prototype, GetElementsByInterface); |
- mixin(DocumentFragment.prototype, NonElementParentNodeInterface); |
- registerWrapper(OriginalDocumentFragment, DocumentFragment, document.createDocumentFragment()); |
- scope.wrappers.DocumentFragment = DocumentFragment; |
var Comment = registerObject(document.createComment("")); |
scope.wrappers.Comment = Comment; |
+ scope.wrappers.DocumentFragment = DocumentFragment; |
})(window.ShadowDOMPolyfill); |
(function(scope) { |
@@ -3370,9 +3302,9 @@ window.ShadowDOMPolyfill = {}; |
var setInnerHTML = scope.setInnerHTML; |
var unsafeUnwrap = scope.unsafeUnwrap; |
var unwrap = scope.unwrap; |
- var wrap = scope.wrap; |
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); |
@@ -3404,24 +3336,9 @@ window.ShadowDOMPolyfill = {}; |
elementFromPoint: function(x, y) { |
return elementFromPoint(this, this.ownerDocument, x, y); |
}, |
- getSelection: function() { |
- return document.getSelection(); |
- }, |
- get activeElement() { |
- var unwrappedActiveElement = unwrap(this).ownerDocument.activeElement; |
- if (!unwrappedActiveElement || !unwrappedActiveElement.nodeType) return null; |
- var activeElement = wrap(unwrappedActiveElement); |
- while (!this.contains(activeElement)) { |
- while (activeElement.parentNode) { |
- activeElement = activeElement.parentNode; |
- } |
- if (activeElement.host) { |
- activeElement = activeElement.host; |
- } else { |
- return null; |
- } |
- } |
- return activeElement; |
+ getElementById: function(id) { |
+ if (spaceCharRe.test(id)) return null; |
+ return this.querySelector('[id="' + id + '"]'); |
} |
}); |
scope.wrappers.ShadowRoot = ShadowRoot; |
@@ -4013,7 +3930,7 @@ window.ShadowDOMPolyfill = {}; |
unsafeUnwrap(this).removeRange(unwrap(range)); |
}, |
selectAllChildren: function(node) { |
- unsafeUnwrap(this).selectAllChildren(node instanceof ShadowRoot ? unsafeUnwrap(node.host) : unwrapIfNeeded(node)); |
+ unsafeUnwrap(this).selectAllChildren(unwrapIfNeeded(node)); |
}, |
toString: function() { |
return unsafeUnwrap(this).toString(); |
@@ -4080,13 +3997,11 @@ window.ShadowDOMPolyfill = {}; |
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; |
var TreeScope = scope.TreeScope; |
var cloneNode = scope.cloneNode; |
- var defineGetter = scope.defineGetter; |
var defineWrapGetter = scope.defineWrapGetter; |
var elementFromPoint = scope.elementFromPoint; |
var forwardMethodsToWrapper = scope.forwardMethodsToWrapper; |
@@ -4110,29 +4025,13 @@ window.ShadowDOMPolyfill = {}; |
defineWrapGetter(Document, "documentElement"); |
defineWrapGetter(Document, "body"); |
defineWrapGetter(Document, "head"); |
- defineGetter(Document, "activeElement", function() { |
- var unwrappedActiveElement = unwrap(this).activeElement; |
- if (!unwrappedActiveElement || !unwrappedActiveElement.nodeType) return null; |
- var activeElement = wrap(unwrappedActiveElement); |
- while (!this.contains(activeElement)) { |
- while (activeElement.parentNode) { |
- activeElement = activeElement.parentNode; |
- } |
- if (activeElement.host) { |
- activeElement = activeElement.host; |
- } else { |
- return null; |
- } |
- } |
- return activeElement; |
- }); |
function wrapMethod(name) { |
var original = document[name]; |
Document.prototype[name] = function() { |
return wrap(original.apply(unsafeUnwrap(this), arguments)); |
}; |
} |
- [ "createComment", "createDocumentFragment", "createElement", "createElementNS", "createEvent", "createEventNS", "createRange", "createTextNode" ].forEach(wrapMethod); |
+ [ "createComment", "createDocumentFragment", "createElement", "createElementNS", "createEvent", "createEventNS", "createRange", "createTextNode", "getElementById" ].forEach(wrapMethod); |
var originalAdoptNode = document.adoptNode; |
function adoptNodeNoRemove(node, doc) { |
originalAdoptNode.call(unsafeUnwrap(doc), unwrap(node)); |
@@ -4256,7 +4155,6 @@ window.ShadowDOMPolyfill = {}; |
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); |
@@ -4275,11 +4173,6 @@ 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() { |
@@ -4293,10 +4186,11 @@ window.ShadowDOMPolyfill = {}; |
}; |
} |
wrapImplMethod(DOMImplementation, "createDocumentType"); |
+ wrapImplMethod(DOMImplementation, "createDocument"); |
wrapImplMethod(DOMImplementation, "createHTMLDocument"); |
forwardImplMethod(DOMImplementation, "hasFeature"); |
registerWrapper(window.DOMImplementation, DOMImplementation); |
- forwardMethodsToWrapper([ window.DOMImplementation ], [ "createDocument", "createDocumentType", "createHTMLDocument", "hasFeature" ]); |
+ forwardMethodsToWrapper([ window.DOMImplementation ], [ "createDocumentType", "createDocument", "createHTMLDocument", "hasFeature" ]); |
scope.adoptNodeNoRemove = adoptNodeNoRemove; |
scope.wrappers.DOMImplementation = DOMImplementation; |
scope.wrappers.Document = Document; |