| Index: polymer_1.0.4/bower_components/webcomponentsjs/webcomponents.js
|
| diff --git a/polymer_0.5.4/bower_components/webcomponentsjs/webcomponents.js b/polymer_1.0.4/bower_components/webcomponentsjs/webcomponents.js
|
| similarity index 88%
|
| copy from polymer_0.5.4/bower_components/webcomponentsjs/webcomponents.js
|
| copy to polymer_1.0.4/bower_components/webcomponentsjs/webcomponents.js
|
| index b22d52b72e1d16f8454849fc6398c957530a7f64..6d7154174e8cc313120fbf1edb33593e1688c775 100644
|
| --- a/polymer_0.5.4/bower_components/webcomponentsjs/webcomponents.js
|
| +++ b/polymer_1.0.4/bower_components/webcomponentsjs/webcomponents.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
|
| window.WebComponents = window.WebComponents || {};
|
|
|
| (function(scope) {
|
| @@ -15,9 +15,12 @@ window.WebComponents = window.WebComponents || {};
|
| var file = "webcomponents.js";
|
| var script = document.querySelector('script[src*="' + file + '"]');
|
| if (!flags.noOpts) {
|
| - location.search.slice(1).split("&").forEach(function(o) {
|
| - o = o.split("=");
|
| - o[0] && (flags[o[0]] = o[1] || true);
|
| + location.search.slice(1).split("&").forEach(function(option) {
|
| + var parts = option.split("=");
|
| + var match;
|
| + if (parts[0] && (match = parts[0].match(/wc-(.+)/))) {
|
| + flags[match[1]] = parts[1] || true;
|
| + }
|
| });
|
| if (script) {
|
| for (var i = 0, a; a = script.attributes[i]; i++) {
|
| @@ -26,7 +29,7 @@ window.WebComponents = window.WebComponents || {};
|
| }
|
| }
|
| }
|
| - if (flags.log) {
|
| + if (flags.log && flags.log.split) {
|
| var parts = flags.log.split(",");
|
| flags.log = {};
|
| parts.forEach(function(f) {
|
| @@ -155,13 +158,20 @@ if (WebComponents.flags.shadow) {
|
| 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) {
|
| @@ -181,7 +191,7 @@ if (WebComponents.flags.shadow) {
|
| 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() {
|
| @@ -221,8 +231,10 @@ if (WebComponents.flags.shadow) {
|
| }
|
| 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);
|
| @@ -230,15 +242,19 @@ if (WebComponents.flags.shadow) {
|
| 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);
|
| @@ -281,7 +297,11 @@ if (WebComponents.flags.shadow) {
|
| 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;
|
| @@ -336,6 +356,7 @@ if (WebComponents.flags.shadow) {
|
| scope.defineGetter = defineGetter;
|
| scope.defineWrapGetter = defineWrapGetter;
|
| scope.forwardMethodsToWrapper = forwardMethodsToWrapper;
|
| + scope.isIdentifierName = isIdentifierName;
|
| scope.isWrapper = isWrapper;
|
| scope.isWrapperFor = isWrapperFor;
|
| scope.mixin = mixin;
|
| @@ -1756,6 +1777,7 @@ if (WebComponents.flags.shadow) {
|
| 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;
|
| @@ -1984,6 +2006,9 @@ if (WebComponents.flags.shadow) {
|
| 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 = [];
|
| @@ -2060,7 +2085,10 @@ if (WebComponents.flags.shadow) {
|
| 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;
|
| @@ -2151,6 +2179,12 @@ if (WebComponents.flags.shadow) {
|
| 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;
|
| @@ -2205,6 +2239,7 @@ if (WebComponents.flags.shadow) {
|
| };
|
| scope.GetElementsByInterface = GetElementsByInterface;
|
| scope.SelectorsInterface = SelectorsInterface;
|
| + scope.MatchesInterface = MatchesInterface;
|
| })(window.ShadowDOMPolyfill);
|
| (function(scope) {
|
| "use strict";
|
| @@ -2257,7 +2292,14 @@ if (WebComponents.flags.shadow) {
|
| 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);
|
| (function(scope) {
|
| @@ -2274,6 +2316,12 @@ if (WebComponents.flags.shadow) {
|
| }
|
| 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;
|
| },
|
| @@ -2327,6 +2375,10 @@ if (WebComponents.flags.shadow) {
|
| })(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) {
|
| @@ -2375,6 +2427,7 @@ if (WebComponents.flags.shadow) {
|
| 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;
|
| @@ -2429,13 +2482,11 @@ if (WebComponents.flags.shadow) {
|
| 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);
|
| }
|
| @@ -2468,9 +2519,11 @@ if (WebComponents.flags.shadow) {
|
| 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);
|
| (function(scope) {
|
| @@ -2522,6 +2575,12 @@ if (WebComponents.flags.shadow) {
|
| }
|
| 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:
|
| @@ -2531,9 +2590,11 @@ if (WebComponents.flags.shadow) {
|
| 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;
|
| @@ -3099,6 +3160,7 @@ if (WebComponents.flags.shadow) {
|
| 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);
|
| @@ -3108,6 +3170,7 @@ if (WebComponents.flags.shadow) {
|
| Object.defineProperty(HTMLElement.prototype, "classList", descr);
|
| delete Element.prototype.classList;
|
| }
|
| + defineWrapGetter(SVGElement, "ownerSVGElement");
|
| scope.wrappers.SVGElement = SVGElement;
|
| })(window.ShadowDOMPolyfill);
|
| (function(scope) {
|
| @@ -3246,30 +3309,126 @@ if (WebComponents.flags.shadow) {
|
| })(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) {
|
| @@ -3331,74 +3490,6 @@ if (WebComponents.flags.shadow) {
|
| })(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;
|
| @@ -3849,7 +3940,7 @@ if (WebComponents.flags.shadow) {
|
| 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);
|
| @@ -3857,9 +3948,6 @@ if (WebComponents.flags.shadow) {
|
| 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));
|
| },
|
| @@ -3873,14 +3961,66 @@ if (WebComponents.flags.shadow) {
|
| 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 +4055,7 @@ if (WebComponents.flags.shadow) {
|
| 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 +4093,25 @@ if (WebComponents.flags.shadow) {
|
| 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 +4175,11 @@ if (WebComponents.flags.shadow) {
|
| }
|
| 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 +4198,11 @@ if (WebComponents.flags.shadow) {
|
| 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 +4216,10 @@ if (WebComponents.flags.shadow) {
|
| };
|
| }
|
| 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;
|
| @@ -4460,7 +4624,7 @@ if (WebComponents.flags.shadow) {
|
| return !selector.match(re);
|
| },
|
| makeScopeMatcher: function(scopeSelector) {
|
| - scopeSelector = scopeSelector.replace(/\[/g, "\\[").replace(/\[/g, "\\]");
|
| + scopeSelector = scopeSelector.replace(/\[/g, "\\[").replace(/\]/g, "\\]");
|
| return new RegExp("^(" + scopeSelector + ")" + selectorReSuffix, "m");
|
| },
|
| applySelectorScope: function(selector, selectorScope) {
|
| @@ -4530,8 +4694,8 @@ if (WebComponents.flags.shadow) {
|
| }
|
| }
|
| };
|
| - var selectorRe = /([^{]*)({[\s\S]*?})/gim, cssCommentRe = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//gim, cssCommentNextSelectorRe = /\/\*\s*@polyfill ([^*]*\*+([^/*][^*]*\*+)*\/)([^{]*?){/gim, cssContentNextSelectorRe = /polyfill-next-selector[^}]*content\:[\s]*?['"](.*?)['"][;\s]*}([^{]*?){/gim, cssCommentRuleRe = /\/\*\s@polyfill-rule([^*]*\*+([^/*][^*]*\*+)*)\//gim, cssContentRuleRe = /(polyfill-rule)[^}]*(content\:[\s]*['"](.*?)['"])[;\s]*[^}]*}/gim, cssCommentUnscopedRuleRe = /\/\*\s@polyfill-unscoped-rule([^*]*\*+([^/*][^*]*\*+)*)\//gim, cssContentUnscopedRuleRe = /(polyfill-unscoped-rule)[^}]*(content\:[\s]*['"](.*?)['"])[;\s]*[^}]*}/gim, cssPseudoRe = /::(x-[^\s{,(]*)/gim, cssPartRe = /::part\(([^)]*)\)/gim, polyfillHost = "-shadowcsshost", polyfillHostContext = "-shadowcsscontext", parenSuffix = ")(?:\\((" + "(?:\\([^)(]*\\)|[^)(]*)+?" + ")\\))?([^,{]*)";
|
| - var cssColonHostRe = new RegExp("(" + polyfillHost + parenSuffix, "gim"), cssColonHostContextRe = new RegExp("(" + polyfillHostContext + parenSuffix, "gim"), selectorReSuffix = "([>\\s~+[.,{:][\\s\\S]*)?$", colonHostRe = /\:host/gim, colonHostContextRe = /\:host-context/gim, polyfillHostNoCombinator = polyfillHost + "-no-combinator", polyfillHostRe = new RegExp(polyfillHost, "gim"), polyfillHostContextRe = new RegExp(polyfillHostContext, "gim"), shadowDOMSelectorsRe = [ /\^\^/g, /\^/g, /\/shadow\//g, /\/shadow-deep\//g, /::shadow/g, /\/deep\//g, /::content/g ];
|
| + var selectorRe = /([^{]*)({[\s\S]*?})/gim, cssCommentRe = /\/\*[^*]*\*+([^\/*][^*]*\*+)*\//gim, cssCommentNextSelectorRe = /\/\*\s*@polyfill ([^*]*\*+([^\/*][^*]*\*+)*\/)([^{]*?){/gim, cssContentNextSelectorRe = /polyfill-next-selector[^}]*content\:[\s]*?['"](.*?)['"][;\s]*}([^{]*?){/gim, cssCommentRuleRe = /\/\*\s@polyfill-rule([^*]*\*+([^\/*][^*]*\*+)*)\//gim, cssContentRuleRe = /(polyfill-rule)[^}]*(content\:[\s]*['"](.*?)['"])[;\s]*[^}]*}/gim, cssCommentUnscopedRuleRe = /\/\*\s@polyfill-unscoped-rule([^*]*\*+([^\/*][^*]*\*+)*)\//gim, cssContentUnscopedRuleRe = /(polyfill-unscoped-rule)[^}]*(content\:[\s]*['"](.*?)['"])[;\s]*[^}]*}/gim, cssPseudoRe = /::(x-[^\s{,(]*)/gim, cssPartRe = /::part\(([^)]*)\)/gim, polyfillHost = "-shadowcsshost", polyfillHostContext = "-shadowcsscontext", parenSuffix = ")(?:\\((" + "(?:\\([^)(]*\\)|[^)(]*)+?" + ")\\))?([^,{]*)";
|
| + var cssColonHostRe = new RegExp("(" + polyfillHost + parenSuffix, "gim"), cssColonHostContextRe = new RegExp("(" + polyfillHostContext + parenSuffix, "gim"), selectorReSuffix = "([>\\s~+[.,{:][\\s\\S]*)?$", colonHostRe = /\:host/gim, colonHostContextRe = /\:host-context/gim, polyfillHostNoCombinator = polyfillHost + "-no-combinator", polyfillHostRe = new RegExp(polyfillHost, "gim"), polyfillHostContextRe = new RegExp(polyfillHostContext, "gim"), shadowDOMSelectorsRe = [ />>>/g, /::shadow/g, /::content/g, /\/deep\//g, /\/shadow\//g, /\/shadow-deep\//g, /\^\^/g, /\^/g ];
|
| function stylesToCssText(styles, preserveComments) {
|
| var cssText = "";
|
| Array.prototype.forEach.call(styles, function(s) {
|
| @@ -4653,7 +4817,7 @@ if (WebComponents.flags.shadow) {
|
| style = elt.ownerDocument.createElement("style");
|
| style.textContent = elt.__resource;
|
| }
|
| - HTMLImports.path.resolveUrlsInStyle(style);
|
| + HTMLImports.path.resolveUrlsInStyle(style, elt.href);
|
| style.textContent = ShadowCSS.shimStyle(style);
|
| style.removeAttribute(SHIM_ATTRIBUTE, "");
|
| style.setAttribute(SHIMMED_ATTRIBUTE, "");
|
| @@ -4695,6 +4859,528 @@ if (WebComponents.flags.shadow) {
|
| }
|
| })(window.WebComponents);
|
|
|
| +(function(scope) {
|
| + "use strict";
|
| + var hasWorkingUrl = false;
|
| + if (!scope.forceJURL) {
|
| + try {
|
| + var u = new URL("b", "http://a");
|
| + u.pathname = "c%20d";
|
| + hasWorkingUrl = u.href === "http://a/c%20d";
|
| + } catch (e) {}
|
| + }
|
| + if (hasWorkingUrl) return;
|
| + var relative = Object.create(null);
|
| + relative["ftp"] = 21;
|
| + relative["file"] = 0;
|
| + relative["gopher"] = 70;
|
| + relative["http"] = 80;
|
| + relative["https"] = 443;
|
| + relative["ws"] = 80;
|
| + relative["wss"] = 443;
|
| + var relativePathDotMapping = Object.create(null);
|
| + relativePathDotMapping["%2e"] = ".";
|
| + relativePathDotMapping[".%2e"] = "..";
|
| + relativePathDotMapping["%2e."] = "..";
|
| + relativePathDotMapping["%2e%2e"] = "..";
|
| + function isRelativeScheme(scheme) {
|
| + return relative[scheme] !== undefined;
|
| + }
|
| + function invalid() {
|
| + clear.call(this);
|
| + this._isInvalid = true;
|
| + }
|
| + function IDNAToASCII(h) {
|
| + if ("" == h) {
|
| + invalid.call(this);
|
| + }
|
| + return h.toLowerCase();
|
| + }
|
| + function percentEscape(c) {
|
| + var unicode = c.charCodeAt(0);
|
| + if (unicode > 32 && unicode < 127 && [ 34, 35, 60, 62, 63, 96 ].indexOf(unicode) == -1) {
|
| + return c;
|
| + }
|
| + return encodeURIComponent(c);
|
| + }
|
| + function percentEscapeQuery(c) {
|
| + var unicode = c.charCodeAt(0);
|
| + if (unicode > 32 && unicode < 127 && [ 34, 35, 60, 62, 96 ].indexOf(unicode) == -1) {
|
| + return c;
|
| + }
|
| + return encodeURIComponent(c);
|
| + }
|
| + var EOF = undefined, ALPHA = /[a-zA-Z]/, ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/;
|
| + function parse(input, stateOverride, base) {
|
| + function err(message) {
|
| + errors.push(message);
|
| + }
|
| + var state = stateOverride || "scheme start", cursor = 0, buffer = "", seenAt = false, seenBracket = false, errors = [];
|
| + loop: while ((input[cursor - 1] != EOF || cursor == 0) && !this._isInvalid) {
|
| + var c = input[cursor];
|
| + switch (state) {
|
| + case "scheme start":
|
| + if (c && ALPHA.test(c)) {
|
| + buffer += c.toLowerCase();
|
| + state = "scheme";
|
| + } else if (!stateOverride) {
|
| + buffer = "";
|
| + state = "no scheme";
|
| + continue;
|
| + } else {
|
| + err("Invalid scheme.");
|
| + break loop;
|
| + }
|
| + break;
|
| +
|
| + case "scheme":
|
| + if (c && ALPHANUMERIC.test(c)) {
|
| + buffer += c.toLowerCase();
|
| + } else if (":" == c) {
|
| + this._scheme = buffer;
|
| + buffer = "";
|
| + if (stateOverride) {
|
| + break loop;
|
| + }
|
| + if (isRelativeScheme(this._scheme)) {
|
| + this._isRelative = true;
|
| + }
|
| + if ("file" == this._scheme) {
|
| + state = "relative";
|
| + } else if (this._isRelative && base && base._scheme == this._scheme) {
|
| + state = "relative or authority";
|
| + } else if (this._isRelative) {
|
| + state = "authority first slash";
|
| + } else {
|
| + state = "scheme data";
|
| + }
|
| + } else if (!stateOverride) {
|
| + buffer = "";
|
| + cursor = 0;
|
| + state = "no scheme";
|
| + continue;
|
| + } else if (EOF == c) {
|
| + break loop;
|
| + } else {
|
| + err("Code point not allowed in scheme: " + c);
|
| + break loop;
|
| + }
|
| + break;
|
| +
|
| + case "scheme data":
|
| + if ("?" == c) {
|
| + this._query = "?";
|
| + state = "query";
|
| + } else if ("#" == c) {
|
| + this._fragment = "#";
|
| + state = "fragment";
|
| + } else {
|
| + if (EOF != c && " " != c && "\n" != c && "\r" != c) {
|
| + this._schemeData += percentEscape(c);
|
| + }
|
| + }
|
| + break;
|
| +
|
| + case "no scheme":
|
| + if (!base || !isRelativeScheme(base._scheme)) {
|
| + err("Missing scheme.");
|
| + invalid.call(this);
|
| + } else {
|
| + state = "relative";
|
| + continue;
|
| + }
|
| + break;
|
| +
|
| + case "relative or authority":
|
| + if ("/" == c && "/" == input[cursor + 1]) {
|
| + state = "authority ignore slashes";
|
| + } else {
|
| + err("Expected /, got: " + c);
|
| + state = "relative";
|
| + continue;
|
| + }
|
| + break;
|
| +
|
| + case "relative":
|
| + this._isRelative = true;
|
| + if ("file" != this._scheme) this._scheme = base._scheme;
|
| + if (EOF == c) {
|
| + this._host = base._host;
|
| + this._port = base._port;
|
| + this._path = base._path.slice();
|
| + this._query = base._query;
|
| + this._username = base._username;
|
| + this._password = base._password;
|
| + break loop;
|
| + } else if ("/" == c || "\\" == c) {
|
| + if ("\\" == c) err("\\ is an invalid code point.");
|
| + state = "relative slash";
|
| + } else if ("?" == c) {
|
| + this._host = base._host;
|
| + this._port = base._port;
|
| + this._path = base._path.slice();
|
| + this._query = "?";
|
| + this._username = base._username;
|
| + this._password = base._password;
|
| + state = "query";
|
| + } else if ("#" == c) {
|
| + this._host = base._host;
|
| + this._port = base._port;
|
| + this._path = base._path.slice();
|
| + this._query = base._query;
|
| + this._fragment = "#";
|
| + this._username = base._username;
|
| + this._password = base._password;
|
| + state = "fragment";
|
| + } else {
|
| + var nextC = input[cursor + 1];
|
| + var nextNextC = input[cursor + 2];
|
| + if ("file" != this._scheme || !ALPHA.test(c) || nextC != ":" && nextC != "|" || EOF != nextNextC && "/" != nextNextC && "\\" != nextNextC && "?" != nextNextC && "#" != nextNextC) {
|
| + this._host = base._host;
|
| + this._port = base._port;
|
| + this._username = base._username;
|
| + this._password = base._password;
|
| + this._path = base._path.slice();
|
| + this._path.pop();
|
| + }
|
| + state = "relative path";
|
| + continue;
|
| + }
|
| + break;
|
| +
|
| + case "relative slash":
|
| + if ("/" == c || "\\" == c) {
|
| + if ("\\" == c) {
|
| + err("\\ is an invalid code point.");
|
| + }
|
| + if ("file" == this._scheme) {
|
| + state = "file host";
|
| + } else {
|
| + state = "authority ignore slashes";
|
| + }
|
| + } else {
|
| + if ("file" != this._scheme) {
|
| + this._host = base._host;
|
| + this._port = base._port;
|
| + this._username = base._username;
|
| + this._password = base._password;
|
| + }
|
| + state = "relative path";
|
| + continue;
|
| + }
|
| + break;
|
| +
|
| + case "authority first slash":
|
| + if ("/" == c) {
|
| + state = "authority second slash";
|
| + } else {
|
| + err("Expected '/', got: " + c);
|
| + state = "authority ignore slashes";
|
| + continue;
|
| + }
|
| + break;
|
| +
|
| + case "authority second slash":
|
| + state = "authority ignore slashes";
|
| + if ("/" != c) {
|
| + err("Expected '/', got: " + c);
|
| + continue;
|
| + }
|
| + break;
|
| +
|
| + case "authority ignore slashes":
|
| + if ("/" != c && "\\" != c) {
|
| + state = "authority";
|
| + continue;
|
| + } else {
|
| + err("Expected authority, got: " + c);
|
| + }
|
| + break;
|
| +
|
| + case "authority":
|
| + if ("@" == c) {
|
| + if (seenAt) {
|
| + err("@ already seen.");
|
| + buffer += "%40";
|
| + }
|
| + seenAt = true;
|
| + for (var i = 0; i < buffer.length; i++) {
|
| + var cp = buffer[i];
|
| + if (" " == cp || "\n" == cp || "\r" == cp) {
|
| + err("Invalid whitespace in authority.");
|
| + continue;
|
| + }
|
| + if (":" == cp && null === this._password) {
|
| + this._password = "";
|
| + continue;
|
| + }
|
| + var tempC = percentEscape(cp);
|
| + null !== this._password ? this._password += tempC : this._username += tempC;
|
| + }
|
| + buffer = "";
|
| + } else if (EOF == c || "/" == c || "\\" == c || "?" == c || "#" == c) {
|
| + cursor -= buffer.length;
|
| + buffer = "";
|
| + state = "host";
|
| + continue;
|
| + } else {
|
| + buffer += c;
|
| + }
|
| + break;
|
| +
|
| + case "file host":
|
| + if (EOF == c || "/" == c || "\\" == c || "?" == c || "#" == c) {
|
| + if (buffer.length == 2 && ALPHA.test(buffer[0]) && (buffer[1] == ":" || buffer[1] == "|")) {
|
| + state = "relative path";
|
| + } else if (buffer.length == 0) {
|
| + state = "relative path start";
|
| + } else {
|
| + this._host = IDNAToASCII.call(this, buffer);
|
| + buffer = "";
|
| + state = "relative path start";
|
| + }
|
| + continue;
|
| + } else if (" " == c || "\n" == c || "\r" == c) {
|
| + err("Invalid whitespace in file host.");
|
| + } else {
|
| + buffer += c;
|
| + }
|
| + break;
|
| +
|
| + case "host":
|
| + case "hostname":
|
| + if (":" == c && !seenBracket) {
|
| + this._host = IDNAToASCII.call(this, buffer);
|
| + buffer = "";
|
| + state = "port";
|
| + if ("hostname" == stateOverride) {
|
| + break loop;
|
| + }
|
| + } else if (EOF == c || "/" == c || "\\" == c || "?" == c || "#" == c) {
|
| + this._host = IDNAToASCII.call(this, buffer);
|
| + buffer = "";
|
| + state = "relative path start";
|
| + if (stateOverride) {
|
| + break loop;
|
| + }
|
| + continue;
|
| + } else if (" " != c && "\n" != c && "\r" != c) {
|
| + if ("[" == c) {
|
| + seenBracket = true;
|
| + } else if ("]" == c) {
|
| + seenBracket = false;
|
| + }
|
| + buffer += c;
|
| + } else {
|
| + err("Invalid code point in host/hostname: " + c);
|
| + }
|
| + break;
|
| +
|
| + case "port":
|
| + if (/[0-9]/.test(c)) {
|
| + buffer += c;
|
| + } else if (EOF == c || "/" == c || "\\" == c || "?" == c || "#" == c || stateOverride) {
|
| + if ("" != buffer) {
|
| + var temp = parseInt(buffer, 10);
|
| + if (temp != relative[this._scheme]) {
|
| + this._port = temp + "";
|
| + }
|
| + buffer = "";
|
| + }
|
| + if (stateOverride) {
|
| + break loop;
|
| + }
|
| + state = "relative path start";
|
| + continue;
|
| + } else if (" " == c || "\n" == c || "\r" == c) {
|
| + err("Invalid code point in port: " + c);
|
| + } else {
|
| + invalid.call(this);
|
| + }
|
| + break;
|
| +
|
| + case "relative path start":
|
| + if ("\\" == c) err("'\\' not allowed in path.");
|
| + state = "relative path";
|
| + if ("/" != c && "\\" != c) {
|
| + continue;
|
| + }
|
| + break;
|
| +
|
| + case "relative path":
|
| + if (EOF == c || "/" == c || "\\" == c || !stateOverride && ("?" == c || "#" == c)) {
|
| + if ("\\" == c) {
|
| + err("\\ not allowed in relative path.");
|
| + }
|
| + var tmp;
|
| + if (tmp = relativePathDotMapping[buffer.toLowerCase()]) {
|
| + buffer = tmp;
|
| + }
|
| + if (".." == buffer) {
|
| + this._path.pop();
|
| + if ("/" != c && "\\" != c) {
|
| + this._path.push("");
|
| + }
|
| + } else if ("." == buffer && "/" != c && "\\" != c) {
|
| + this._path.push("");
|
| + } else if ("." != buffer) {
|
| + if ("file" == this._scheme && this._path.length == 0 && buffer.length == 2 && ALPHA.test(buffer[0]) && buffer[1] == "|") {
|
| + buffer = buffer[0] + ":";
|
| + }
|
| + this._path.push(buffer);
|
| + }
|
| + buffer = "";
|
| + if ("?" == c) {
|
| + this._query = "?";
|
| + state = "query";
|
| + } else if ("#" == c) {
|
| + this._fragment = "#";
|
| + state = "fragment";
|
| + }
|
| + } else if (" " != c && "\n" != c && "\r" != c) {
|
| + buffer += percentEscape(c);
|
| + }
|
| + break;
|
| +
|
| + case "query":
|
| + if (!stateOverride && "#" == c) {
|
| + this._fragment = "#";
|
| + state = "fragment";
|
| + } else if (EOF != c && " " != c && "\n" != c && "\r" != c) {
|
| + this._query += percentEscapeQuery(c);
|
| + }
|
| + break;
|
| +
|
| + case "fragment":
|
| + if (EOF != c && " " != c && "\n" != c && "\r" != c) {
|
| + this._fragment += c;
|
| + }
|
| + break;
|
| + }
|
| + cursor++;
|
| + }
|
| + }
|
| + function clear() {
|
| + this._scheme = "";
|
| + this._schemeData = "";
|
| + this._username = "";
|
| + this._password = null;
|
| + this._host = "";
|
| + this._port = "";
|
| + this._path = [];
|
| + this._query = "";
|
| + this._fragment = "";
|
| + this._isInvalid = false;
|
| + this._isRelative = false;
|
| + }
|
| + function jURL(url, base) {
|
| + if (base !== undefined && !(base instanceof jURL)) base = new jURL(String(base));
|
| + this._url = url;
|
| + clear.call(this);
|
| + var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, "");
|
| + parse.call(this, input, null, base);
|
| + }
|
| + jURL.prototype = {
|
| + toString: function() {
|
| + return this.href;
|
| + },
|
| + get href() {
|
| + if (this._isInvalid) return this._url;
|
| + var authority = "";
|
| + if ("" != this._username || null != this._password) {
|
| + authority = this._username + (null != this._password ? ":" + this._password : "") + "@";
|
| + }
|
| + return this.protocol + (this._isRelative ? "//" + authority + this.host : "") + this.pathname + this._query + this._fragment;
|
| + },
|
| + set href(href) {
|
| + clear.call(this);
|
| + parse.call(this, href);
|
| + },
|
| + get protocol() {
|
| + return this._scheme + ":";
|
| + },
|
| + set protocol(protocol) {
|
| + if (this._isInvalid) return;
|
| + parse.call(this, protocol + ":", "scheme start");
|
| + },
|
| + get host() {
|
| + return this._isInvalid ? "" : this._port ? this._host + ":" + this._port : this._host;
|
| + },
|
| + set host(host) {
|
| + if (this._isInvalid || !this._isRelative) return;
|
| + parse.call(this, host, "host");
|
| + },
|
| + get hostname() {
|
| + return this._host;
|
| + },
|
| + set hostname(hostname) {
|
| + if (this._isInvalid || !this._isRelative) return;
|
| + parse.call(this, hostname, "hostname");
|
| + },
|
| + get port() {
|
| + return this._port;
|
| + },
|
| + set port(port) {
|
| + if (this._isInvalid || !this._isRelative) return;
|
| + parse.call(this, port, "port");
|
| + },
|
| + get pathname() {
|
| + return this._isInvalid ? "" : this._isRelative ? "/" + this._path.join("/") : this._schemeData;
|
| + },
|
| + set pathname(pathname) {
|
| + if (this._isInvalid || !this._isRelative) return;
|
| + this._path = [];
|
| + parse.call(this, pathname, "relative path start");
|
| + },
|
| + get search() {
|
| + return this._isInvalid || !this._query || "?" == this._query ? "" : this._query;
|
| + },
|
| + set search(search) {
|
| + if (this._isInvalid || !this._isRelative) return;
|
| + this._query = "?";
|
| + if ("?" == search[0]) search = search.slice(1);
|
| + parse.call(this, search, "query");
|
| + },
|
| + get hash() {
|
| + return this._isInvalid || !this._fragment || "#" == this._fragment ? "" : this._fragment;
|
| + },
|
| + set hash(hash) {
|
| + if (this._isInvalid) return;
|
| + this._fragment = "#";
|
| + if ("#" == hash[0]) hash = hash.slice(1);
|
| + parse.call(this, hash, "fragment");
|
| + },
|
| + get origin() {
|
| + var host;
|
| + if (this._isInvalid || !this._scheme) {
|
| + return "";
|
| + }
|
| + switch (this._scheme) {
|
| + case "data":
|
| + case "file":
|
| + case "javascript":
|
| + case "mailto":
|
| + return "null";
|
| + }
|
| + host = this.host;
|
| + if (!host) {
|
| + return "";
|
| + }
|
| + return this._scheme + "://" + host;
|
| + }
|
| + };
|
| + var OriginalURL = scope.URL;
|
| + if (OriginalURL) {
|
| + jURL.createObjectURL = function(blob) {
|
| + return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
|
| + };
|
| + jURL.revokeObjectURL = function(url) {
|
| + OriginalURL.revokeObjectURL(url);
|
| + };
|
| + }
|
| + scope.URL = jURL;
|
| +})(this);
|
| +
|
| (function(global) {
|
| var registrationsTable = new WeakMap();
|
| var setImmediate;
|
| @@ -4966,7 +5652,6 @@ if (WebComponents.flags.shadow) {
|
| this.addTransientObserver(e.target);
|
|
|
| case "DOMNodeInserted":
|
| - var target = e.relatedNode;
|
| var changedNode = e.target;
|
| var addedNodes, removedNodes;
|
| if (e.type === "DOMNodeInserted") {
|
| @@ -4978,12 +5663,12 @@ if (WebComponents.flags.shadow) {
|
| }
|
| var previousSibling = changedNode.previousSibling;
|
| var nextSibling = changedNode.nextSibling;
|
| - var record = getRecord("childList", target);
|
| + var record = getRecord("childList", e.target.parentNode);
|
| record.addedNodes = addedNodes;
|
| record.removedNodes = removedNodes;
|
| record.previousSibling = previousSibling;
|
| record.nextSibling = nextSibling;
|
| - forEachAncestorAndObserverEnqueueRecord(target, function(options) {
|
| + forEachAncestorAndObserverEnqueueRecord(e.relatedNode, function(options) {
|
| if (!options.childList) return;
|
| return record;
|
| });
|
| @@ -5004,19 +5689,19 @@ window.HTMLImports = window.HTMLImports || {
|
| var useNative = Boolean(IMPORT_LINK_TYPE in document.createElement("link"));
|
| var hasShadowDOMPolyfill = Boolean(window.ShadowDOMPolyfill);
|
| var wrap = function(node) {
|
| - return hasShadowDOMPolyfill ? ShadowDOMPolyfill.wrapIfNeeded(node) : node;
|
| + return hasShadowDOMPolyfill ? window.ShadowDOMPolyfill.wrapIfNeeded(node) : node;
|
| };
|
| var rootDocument = wrap(document);
|
| var currentScriptDescriptor = {
|
| get: function() {
|
| - var script = HTMLImports.currentScript || document.currentScript || (document.readyState !== "complete" ? document.scripts[document.scripts.length - 1] : null);
|
| + var script = window.HTMLImports.currentScript || document.currentScript || (document.readyState !== "complete" ? document.scripts[document.scripts.length - 1] : null);
|
| return wrap(script);
|
| },
|
| configurable: true
|
| };
|
| Object.defineProperty(document, "_currentScript", currentScriptDescriptor);
|
| Object.defineProperty(rootDocument, "_currentScript", currentScriptDescriptor);
|
| - var isIE = /Trident|Edge/.test(navigator.userAgent);
|
| + var isIE = /Trident/.test(navigator.userAgent);
|
| function whenReady(callback, doc) {
|
| doc = doc || rootDocument;
|
| whenDocumentReady(function() {
|
| @@ -5046,26 +5731,35 @@ window.HTMLImports = window.HTMLImports || {
|
| }
|
| function watchImportsLoad(callback, doc) {
|
| var imports = doc.querySelectorAll("link[rel=import]");
|
| - var loaded = 0, l = imports.length;
|
| - function checkDone(d) {
|
| - if (loaded == l && callback) {
|
| - callback();
|
| + var parsedCount = 0, importCount = imports.length, newImports = [], errorImports = [];
|
| + function checkDone() {
|
| + if (parsedCount == importCount && callback) {
|
| + callback({
|
| + allImports: imports,
|
| + loadedImports: newImports,
|
| + errorImports: errorImports
|
| + });
|
| }
|
| }
|
| function loadedImport(e) {
|
| markTargetLoaded(e);
|
| - loaded++;
|
| + newImports.push(this);
|
| + parsedCount++;
|
| + checkDone();
|
| + }
|
| + function errorLoadingImport(e) {
|
| + errorImports.push(this);
|
| + parsedCount++;
|
| checkDone();
|
| }
|
| - if (l) {
|
| - for (var i = 0, imp; i < l && (imp = imports[i]); i++) {
|
| + if (importCount) {
|
| + for (var i = 0, imp; i < importCount && (imp = imports[i]); i++) {
|
| if (isImportLoaded(imp)) {
|
| - loadedImport.call(imp, {
|
| - target: imp
|
| - });
|
| + parsedCount++;
|
| + checkDone();
|
| } else {
|
| imp.addEventListener("load", loadedImport);
|
| - imp.addEventListener("error", loadedImport);
|
| + imp.addEventListener("error", errorLoadingImport);
|
| }
|
| }
|
| } else {
|
| @@ -5115,11 +5809,11 @@ window.HTMLImports = window.HTMLImports || {
|
| }
|
| })();
|
| }
|
| - whenReady(function() {
|
| - HTMLImports.ready = true;
|
| - HTMLImports.readyTime = new Date().getTime();
|
| + whenReady(function(detail) {
|
| + window.HTMLImports.ready = true;
|
| + window.HTMLImports.readyTime = new Date().getTime();
|
| var evt = rootDocument.createEvent("CustomEvent");
|
| - evt.initCustomEvent("HTMLImportsLoaded", true, true, {});
|
| + evt.initCustomEvent("HTMLImportsLoaded", true, true, detail);
|
| rootDocument.dispatchEvent(evt);
|
| });
|
| scope.IMPORT_LINK_TYPE = IMPORT_LINK_TYPE;
|
| @@ -5127,7 +5821,7 @@ window.HTMLImports = window.HTMLImports || {
|
| scope.rootDocument = rootDocument;
|
| scope.whenReady = whenReady;
|
| scope.isIE = isIE;
|
| -})(HTMLImports);
|
| +})(window.HTMLImports);
|
|
|
| (function(scope) {
|
| var modules = [];
|
| @@ -5141,26 +5835,29 @@ window.HTMLImports = window.HTMLImports || {
|
| };
|
| scope.addModule = addModule;
|
| scope.initializeModules = initializeModules;
|
| -})(HTMLImports);
|
| +})(window.HTMLImports);
|
|
|
| -HTMLImports.addModule(function(scope) {
|
| +window.HTMLImports.addModule(function(scope) {
|
| var CSS_URL_REGEXP = /(url\()([^)]*)(\))/g;
|
| var CSS_IMPORT_REGEXP = /(@import[\s]+(?!url\())([^;]*)(;)/g;
|
| var path = {
|
| - resolveUrlsInStyle: function(style) {
|
| + resolveUrlsInStyle: function(style, linkUrl) {
|
| var doc = style.ownerDocument;
|
| var resolver = doc.createElement("a");
|
| - style.textContent = this.resolveUrlsInCssText(style.textContent, resolver);
|
| + style.textContent = this.resolveUrlsInCssText(style.textContent, linkUrl, resolver);
|
| return style;
|
| },
|
| - resolveUrlsInCssText: function(cssText, urlObj) {
|
| - var r = this.replaceUrls(cssText, urlObj, CSS_URL_REGEXP);
|
| - r = this.replaceUrls(r, urlObj, CSS_IMPORT_REGEXP);
|
| + resolveUrlsInCssText: function(cssText, linkUrl, urlObj) {
|
| + var r = this.replaceUrls(cssText, urlObj, linkUrl, CSS_URL_REGEXP);
|
| + r = this.replaceUrls(r, urlObj, linkUrl, CSS_IMPORT_REGEXP);
|
| return r;
|
| },
|
| - replaceUrls: function(text, urlObj, regexp) {
|
| + replaceUrls: function(text, urlObj, linkUrl, regexp) {
|
| return text.replace(regexp, function(m, pre, url, post) {
|
| var urlPath = url.replace(/["']/g, "");
|
| + if (linkUrl) {
|
| + urlPath = new URL(urlPath, linkUrl).href;
|
| + }
|
| urlObj.href = urlPath;
|
| urlPath = urlObj.href;
|
| return pre + "'" + urlPath + "'" + post;
|
| @@ -5170,7 +5867,7 @@ HTMLImports.addModule(function(scope) {
|
| scope.path = path;
|
| });
|
|
|
| -HTMLImports.addModule(function(scope) {
|
| +window.HTMLImports.addModule(function(scope) {
|
| var xhr = {
|
| async: true,
|
| ok: function(request) {
|
| @@ -5202,7 +5899,7 @@ HTMLImports.addModule(function(scope) {
|
| scope.xhr = xhr;
|
| });
|
|
|
| -HTMLImports.addModule(function(scope) {
|
| +window.HTMLImports.addModule(function(scope) {
|
| var xhr = scope.xhr;
|
| var flags = scope.flags;
|
| var Loader = function(onLoad, onComplete) {
|
| @@ -5295,7 +5992,7 @@ HTMLImports.addModule(function(scope) {
|
| scope.Loader = Loader;
|
| });
|
|
|
| -HTMLImports.addModule(function(scope) {
|
| +window.HTMLImports.addModule(function(scope) {
|
| var Observer = function(addCallback) {
|
| this.addCallback = addCallback;
|
| this.mo = new MutationObserver(this.handler.bind(this));
|
| @@ -5328,7 +6025,7 @@ HTMLImports.addModule(function(scope) {
|
| scope.Observer = Observer;
|
| });
|
|
|
| -HTMLImports.addModule(function(scope) {
|
| +window.HTMLImports.addModule(function(scope) {
|
| var path = scope.path;
|
| var rootDocument = scope.rootDocument;
|
| var flags = scope.flags;
|
| @@ -5337,7 +6034,7 @@ HTMLImports.addModule(function(scope) {
|
| var IMPORT_SELECTOR = "link[rel=" + IMPORT_LINK_TYPE + "]";
|
| var importParser = {
|
| documentSelectors: IMPORT_SELECTOR,
|
| - importsSelectors: [ IMPORT_SELECTOR, "link[rel=stylesheet]", "style", "script:not([type])", 'script[type="text/javascript"]' ].join(","),
|
| + importsSelectors: [ IMPORT_SELECTOR, "link[rel=stylesheet]", "style", "script:not([type])", 'script[type="application/javascript"]', 'script[type="text/javascript"]' ].join(","),
|
| map: {
|
| link: "parseLink",
|
| script: "parseScript",
|
| @@ -5388,8 +6085,8 @@ HTMLImports.addModule(function(scope) {
|
| }
|
| },
|
| parseImport: function(elt) {
|
| - if (HTMLImports.__importsParsingHook) {
|
| - HTMLImports.__importsParsingHook(elt);
|
| + if (window.HTMLImports.__importsParsingHook) {
|
| + window.HTMLImports.__importsParsingHook(elt);
|
| }
|
| if (elt.import) {
|
| elt.import.__importParsed = true;
|
| @@ -5428,6 +6125,7 @@ HTMLImports.addModule(function(scope) {
|
| parseStyle: function(elt) {
|
| var src = elt;
|
| elt = cloneStyle(elt);
|
| + src.__appliedElement = elt;
|
| elt.__importElement = src;
|
| this.parseGeneric(elt);
|
| },
|
| @@ -5472,9 +6170,11 @@ HTMLImports.addModule(function(scope) {
|
| }
|
| }
|
| if (fakeLoad) {
|
| - elt.dispatchEvent(new CustomEvent("load", {
|
| - bubbles: false
|
| - }));
|
| + setTimeout(function() {
|
| + elt.dispatchEvent(new CustomEvent("load", {
|
| + bubbles: false
|
| + }));
|
| + });
|
| }
|
| }
|
| },
|
| @@ -5557,7 +6257,7 @@ HTMLImports.addModule(function(scope) {
|
| scope.IMPORT_SELECTOR = IMPORT_SELECTOR;
|
| });
|
|
|
| -HTMLImports.addModule(function(scope) {
|
| +window.HTMLImports.addModule(function(scope) {
|
| var flags = scope.flags;
|
| var IMPORT_LINK_TYPE = scope.IMPORT_LINK_TYPE;
|
| var IMPORT_SELECTOR = scope.IMPORT_SELECTOR;
|
| @@ -5618,12 +6318,15 @@ HTMLImports.addModule(function(scope) {
|
| function isLinkRel(elt, rel) {
|
| return elt.localName === "link" && elt.getAttribute("rel") === rel;
|
| }
|
| + function hasBaseURIAccessor(doc) {
|
| + return !!Object.getOwnPropertyDescriptor(doc, "baseURI");
|
| + }
|
| function makeDocument(resource, url) {
|
| var doc = document.implementation.createHTMLDocument(IMPORT_LINK_TYPE);
|
| doc._URL = url;
|
| var base = doc.createElement("base");
|
| base.setAttribute("href", url);
|
| - if (!doc.baseURI) {
|
| + if (!doc.baseURI && !hasBaseURIAccessor(doc)) {
|
| Object.defineProperty(doc, "baseURI", {
|
| value: url
|
| });
|
| @@ -5653,7 +6356,7 @@ HTMLImports.addModule(function(scope) {
|
| scope.importLoader = importLoader;
|
| });
|
|
|
| -HTMLImports.addModule(function(scope) {
|
| +window.HTMLImports.addModule(function(scope) {
|
| var parser = scope.parser;
|
| var importer = scope.importer;
|
| var dynamic = {
|
| @@ -5695,6 +6398,13 @@ HTMLImports.addModule(function(scope) {
|
| params = params || {};
|
| var e = document.createEvent("CustomEvent");
|
| e.initCustomEvent(inType, Boolean(params.bubbles), Boolean(params.cancelable), params.detail);
|
| + e.preventDefault = function() {
|
| + Object.defineProperty(this, "defaultPrevented", {
|
| + get: function() {
|
| + return true;
|
| + }
|
| + });
|
| + };
|
| return e;
|
| };
|
| window.CustomEvent.prototype = window.Event.prototype;
|
| @@ -5702,14 +6412,14 @@ HTMLImports.addModule(function(scope) {
|
| initializeModules();
|
| var rootDocument = scope.rootDocument;
|
| function bootstrap() {
|
| - HTMLImports.importer.bootDocument(rootDocument);
|
| + window.HTMLImports.importer.bootDocument(rootDocument);
|
| }
|
| if (document.readyState === "complete" || document.readyState === "interactive" && !window.attachEvent) {
|
| bootstrap();
|
| } else {
|
| document.addEventListener("DOMContentLoaded", bootstrap);
|
| }
|
| -})(HTMLImports);
|
| +})(window.HTMLImports);
|
|
|
| window.CustomElements = window.CustomElements || {
|
| flags: {}
|
| @@ -5729,11 +6439,11 @@ window.CustomElements = window.CustomElements || {
|
| scope.addModule = addModule;
|
| scope.initializeModules = initializeModules;
|
| scope.hasNative = Boolean(document.registerElement);
|
| - scope.useNative = !flags.register && scope.hasNative && !window.ShadowDOMPolyfill && (!window.HTMLImports || HTMLImports.useNative);
|
| -})(CustomElements);
|
| + scope.useNative = !flags.register && scope.hasNative && !window.ShadowDOMPolyfill && (!window.HTMLImports || window.HTMLImports.useNative);
|
| +})(window.CustomElements);
|
|
|
| -CustomElements.addModule(function(scope) {
|
| - var IMPORT_LINK_TYPE = window.HTMLImports ? HTMLImports.IMPORT_LINK_TYPE : "none";
|
| +window.CustomElements.addModule(function(scope) {
|
| + var IMPORT_LINK_TYPE = window.HTMLImports ? window.HTMLImports.IMPORT_LINK_TYPE : "none";
|
| function forSubtree(node, cb) {
|
| findAllElements(node, function(e) {
|
| if (cb(e)) {
|
| @@ -5766,14 +6476,11 @@ CustomElements.addModule(function(scope) {
|
| root = root.olderShadowRoot;
|
| }
|
| }
|
| - var processingDocuments;
|
| function forDocumentTree(doc, cb) {
|
| - processingDocuments = [];
|
| - _forDocumentTree(doc, cb);
|
| - processingDocuments = null;
|
| + _forDocumentTree(doc, cb, []);
|
| }
|
| - function _forDocumentTree(doc, cb) {
|
| - doc = wrap(doc);
|
| + function _forDocumentTree(doc, cb, processingDocuments) {
|
| + doc = window.wrap(doc);
|
| if (processingDocuments.indexOf(doc) >= 0) {
|
| return;
|
| }
|
| @@ -5781,7 +6488,7 @@ CustomElements.addModule(function(scope) {
|
| var imports = doc.querySelectorAll("link[rel=" + IMPORT_LINK_TYPE + "]");
|
| for (var i = 0, l = imports.length, n; i < l && (n = imports[i]); i++) {
|
| if (n.import) {
|
| - _forDocumentTree(n.import, cb);
|
| + _forDocumentTree(n.import, cb, processingDocuments);
|
| }
|
| }
|
| cb(doc);
|
| @@ -5790,7 +6497,7 @@ CustomElements.addModule(function(scope) {
|
| scope.forSubtree = forSubtree;
|
| });
|
|
|
| -CustomElements.addModule(function(scope) {
|
| +window.CustomElements.addModule(function(scope) {
|
| var flags = scope.flags;
|
| var forSubtree = scope.forSubtree;
|
| var forDocumentTree = scope.forDocumentTree;
|
| @@ -5888,7 +6595,7 @@ CustomElements.addModule(function(scope) {
|
| if (p == doc) {
|
| return true;
|
| }
|
| - p = p.parentNode || p.host;
|
| + p = p.parentNode || p.nodeType === Node.DOCUMENT_FRAGMENT_NODE && p.host;
|
| }
|
| }
|
| function watchShadow(node) {
|
| @@ -5935,9 +6642,9 @@ CustomElements.addModule(function(scope) {
|
| flags.dom && console.groupEnd();
|
| }
|
| function takeRecords(node) {
|
| - node = wrap(node);
|
| + node = window.wrap(node);
|
| if (!node) {
|
| - node = wrap(document);
|
| + node = window.wrap(document);
|
| }
|
| while (node.parentNode) {
|
| node = node.parentNode;
|
| @@ -5961,7 +6668,7 @@ CustomElements.addModule(function(scope) {
|
| inRoot.__observer = observer;
|
| }
|
| function upgradeDocument(doc) {
|
| - doc = wrap(doc);
|
| + doc = window.wrap(doc);
|
| flags.dom && console.group("upgradeDocument: ", doc.baseURI.split("/").pop());
|
| addedNode(doc);
|
| observe(doc);
|
| @@ -5971,11 +6678,13 @@ CustomElements.addModule(function(scope) {
|
| forDocumentTree(doc, upgradeDocument);
|
| }
|
| var originalCreateShadowRoot = Element.prototype.createShadowRoot;
|
| - Element.prototype.createShadowRoot = function() {
|
| - var root = originalCreateShadowRoot.call(this);
|
| - CustomElements.watchShadow(this);
|
| - return root;
|
| - };
|
| + if (originalCreateShadowRoot) {
|
| + Element.prototype.createShadowRoot = function() {
|
| + var root = originalCreateShadowRoot.call(this);
|
| + window.CustomElements.watchShadow(this);
|
| + return root;
|
| + };
|
| + }
|
| scope.watchShadow = watchShadow;
|
| scope.upgradeDocumentTree = upgradeDocumentTree;
|
| scope.upgradeSubtree = addedSubtree;
|
| @@ -5984,7 +6693,7 @@ CustomElements.addModule(function(scope) {
|
| scope.takeRecords = takeRecords;
|
| });
|
|
|
| -CustomElements.addModule(function(scope) {
|
| +window.CustomElements.addModule(function(scope) {
|
| var flags = scope.flags;
|
| function upgrade(node) {
|
| if (!node.__upgraded__ && node.nodeType === Node.ELEMENT_NODE) {
|
| @@ -6044,9 +6753,10 @@ CustomElements.addModule(function(scope) {
|
| scope.implementPrototype = implementPrototype;
|
| });
|
|
|
| -CustomElements.addModule(function(scope) {
|
| +window.CustomElements.addModule(function(scope) {
|
| + var isIE11OrOlder = scope.isIE11OrOlder;
|
| var upgradeDocumentTree = scope.upgradeDocumentTree;
|
| - var upgrade = scope.upgrade;
|
| + var upgradeAll = scope.upgradeAll;
|
| var upgradeWithDefinition = scope.upgradeWithDefinition;
|
| var implementPrototype = scope.implementPrototype;
|
| var useNative = scope.useNative;
|
| @@ -6175,6 +6885,12 @@ CustomElements.addModule(function(scope) {
|
| }
|
| }
|
| function createElement(tag, typeExtension) {
|
| + if (tag) {
|
| + tag = tag.toLowerCase();
|
| + }
|
| + if (typeExtension) {
|
| + typeExtension = typeExtension.toLowerCase();
|
| + }
|
| var definition = getRegisteredDefinition(typeExtension || tag);
|
| if (definition) {
|
| if (tag == definition.tag && typeExtension == definition.is) {
|
| @@ -6196,14 +6912,8 @@ CustomElements.addModule(function(scope) {
|
| }
|
| return element;
|
| }
|
| - function cloneNode(deep) {
|
| - var n = domCloneNode.call(this, deep);
|
| - upgrade(n);
|
| - return n;
|
| - }
|
| var domCreateElement = document.createElement.bind(document);
|
| var domCreateElementNS = document.createElementNS.bind(document);
|
| - var domCloneNode = Node.prototype.cloneNode;
|
| var isInstance;
|
| if (!Object.__proto__ && !useNative) {
|
| isInstance = function(obj, ctor) {
|
| @@ -6221,10 +6931,34 @@ CustomElements.addModule(function(scope) {
|
| return obj instanceof base;
|
| };
|
| }
|
| + function wrapDomMethodToForceUpgrade(obj, methodName) {
|
| + var orig = obj[methodName];
|
| + obj[methodName] = function() {
|
| + var n = orig.apply(this, arguments);
|
| + upgradeAll(n);
|
| + return n;
|
| + };
|
| + }
|
| + wrapDomMethodToForceUpgrade(Node.prototype, "cloneNode");
|
| + wrapDomMethodToForceUpgrade(document, "importNode");
|
| + if (isIE11OrOlder) {
|
| + (function() {
|
| + var importNode = document.importNode;
|
| + document.importNode = function() {
|
| + var n = importNode.apply(document, arguments);
|
| + if (n.nodeType == n.DOCUMENT_FRAGMENT_NODE) {
|
| + var f = document.createDocumentFragment();
|
| + f.appendChild(n);
|
| + return f;
|
| + } else {
|
| + return n;
|
| + }
|
| + };
|
| + })();
|
| + }
|
| document.registerElement = register;
|
| document.createElement = createElement;
|
| document.createElementNS = createElementNS;
|
| - Node.prototype.cloneNode = cloneNode;
|
| scope.registry = registry;
|
| scope.instanceof = isInstance;
|
| scope.reservedTagList = reservedTagList;
|
| @@ -6253,8 +6987,8 @@ CustomElements.addModule(function(scope) {
|
| var upgradeDocumentTree = scope.upgradeDocumentTree;
|
| if (!window.wrap) {
|
| if (window.ShadowDOMPolyfill) {
|
| - window.wrap = ShadowDOMPolyfill.wrapIfNeeded;
|
| - window.unwrap = ShadowDOMPolyfill.unwrapIfNeeded;
|
| + window.wrap = window.ShadowDOMPolyfill.wrapIfNeeded;
|
| + window.unwrap = window.ShadowDOMPolyfill.unwrapIfNeeded;
|
| } else {
|
| window.wrap = window.unwrap = function(node) {
|
| return node;
|
| @@ -6262,17 +6996,17 @@ CustomElements.addModule(function(scope) {
|
| }
|
| }
|
| function bootstrap() {
|
| - upgradeDocumentTree(wrap(document));
|
| + upgradeDocumentTree(window.wrap(document));
|
| if (window.HTMLImports) {
|
| - HTMLImports.__importsParsingHook = function(elt) {
|
| + window.HTMLImports.__importsParsingHook = function(elt) {
|
| upgradeDocumentTree(wrap(elt.import));
|
| };
|
| }
|
| - CustomElements.ready = true;
|
| + window.CustomElements.ready = true;
|
| setTimeout(function() {
|
| - CustomElements.readyTime = Date.now();
|
| + window.CustomElements.readyTime = Date.now();
|
| if (window.HTMLImports) {
|
| - CustomElements.elapsed = CustomElements.readyTime - HTMLImports.readyTime;
|
| + window.CustomElements.elapsed = window.CustomElements.readyTime - window.HTMLImports.readyTime;
|
| }
|
| document.dispatchEvent(new CustomEvent("WebComponentsReady", {
|
| bubbles: true
|
| @@ -6284,6 +7018,13 @@ CustomElements.addModule(function(scope) {
|
| params = params || {};
|
| var e = document.createEvent("CustomEvent");
|
| e.initCustomEvent(inType, Boolean(params.bubbles), Boolean(params.cancelable), params.detail);
|
| + e.preventDefault = function() {
|
| + Object.defineProperty(this, "defaultPrevented", {
|
| + get: function() {
|
| + return true;
|
| + }
|
| + });
|
| + };
|
| return e;
|
| };
|
| window.CustomEvent.prototype = window.Event.prototype;
|
| @@ -6293,9 +7034,10 @@ CustomElements.addModule(function(scope) {
|
| } else if (document.readyState === "interactive" && !window.attachEvent && (!window.HTMLImports || window.HTMLImports.ready)) {
|
| bootstrap();
|
| } else {
|
| - var loadEvent = window.HTMLImports && !HTMLImports.ready ? "HTMLImportsLoaded" : "DOMContentLoaded";
|
| + var loadEvent = window.HTMLImports && !window.HTMLImports.ready ? "HTMLImportsLoaded" : "DOMContentLoaded";
|
| window.addEventListener(loadEvent, bootstrap);
|
| }
|
| + scope.isIE11OrOlder = isIE11OrOlder;
|
| })(window.CustomElements);
|
|
|
| (function(scope) {
|
| @@ -6368,7 +7110,7 @@ CustomElements.addModule(function(scope) {
|
| if (HTMLImports.useNative) {
|
| installPolymerWarning();
|
| } else {
|
| - addEventListener("DOMContentLoaded", installPolymerWarning);
|
| + window.addEventListener("DOMContentLoaded", installPolymerWarning);
|
| }
|
| })(window.WebComponents);
|
|
|
|
|