| OLD | NEW |
| 1 /** | 1 /** |
| 2 * @license | 2 * @license |
| 3 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. | 3 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
| 4 * This code may only be used under the BSD style license found at http://polyme
r.github.io/LICENSE.txt | 4 * This code may only be used under the BSD style license found at http://polyme
r.github.io/LICENSE.txt |
| 5 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.
txt | 5 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.
txt |
| 6 * The complete set of contributors may be found at http://polymer.github.io/CON
TRIBUTORS.txt | 6 * The complete set of contributors may be found at http://polymer.github.io/CON
TRIBUTORS.txt |
| 7 * Code distributed by Google as part of the polymer project is also | 7 * Code distributed by Google as part of the polymer project is also |
| 8 * subject to an additional IP rights grant found at http://polymer.github.io/PA
TENTS.txt | 8 * subject to an additional IP rights grant found at http://polymer.github.io/PA
TENTS.txt |
| 9 */ | 9 */ |
| 10 // @version 0.5.1-1 | 10 // @version 0.5.4 |
| 11 if (typeof WeakMap === "undefined") { | 11 if (typeof WeakMap === "undefined") { |
| 12 (function() { | 12 (function() { |
| 13 var defineProperty = Object.defineProperty; | 13 var defineProperty = Object.defineProperty; |
| 14 var counter = Date.now() % 1e9; | 14 var counter = Date.now() % 1e9; |
| 15 var WeakMap = function() { | 15 var WeakMap = function() { |
| 16 this.name = "__st" + (Math.random() * 1e9 >>> 0) + (counter++ + "__"); | 16 this.name = "__st" + (Math.random() * 1e9 >>> 0) + (counter++ + "__"); |
| 17 }; | 17 }; |
| 18 WeakMap.prototype = { | 18 WeakMap.prototype = { |
| 19 set: function(key, value) { | 19 set: function(key, value) { |
| 20 var entry = key[this.name]; | 20 var entry = key[this.name]; |
| (...skipping 1931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1952 return originalCompareDocumentPosition.call(unsafeUnwrap(this), unwrapIfNe
eded(otherNode)); | 1952 return originalCompareDocumentPosition.call(unsafeUnwrap(this), unwrapIfNe
eded(otherNode)); |
| 1953 }, | 1953 }, |
| 1954 normalize: function() { | 1954 normalize: function() { |
| 1955 var nodes = snapshotNodeList(this.childNodes); | 1955 var nodes = snapshotNodeList(this.childNodes); |
| 1956 var remNodes = []; | 1956 var remNodes = []; |
| 1957 var s = ""; | 1957 var s = ""; |
| 1958 var modNode; | 1958 var modNode; |
| 1959 for (var i = 0, n; i < nodes.length; i++) { | 1959 for (var i = 0, n; i < nodes.length; i++) { |
| 1960 n = nodes[i]; | 1960 n = nodes[i]; |
| 1961 if (n.nodeType === Node.TEXT_NODE) { | 1961 if (n.nodeType === Node.TEXT_NODE) { |
| 1962 if (!modNode && !n.data.length) this.removeNode(n); else if (!modNode)
modNode = n; else { | 1962 if (!modNode && !n.data.length) this.removeChild(n); else if (!modNode
) modNode = n; else { |
| 1963 s += n.data; | 1963 s += n.data; |
| 1964 remNodes.push(n); | 1964 remNodes.push(n); |
| 1965 } | 1965 } |
| 1966 } else { | 1966 } else { |
| 1967 if (modNode && remNodes.length) { | 1967 if (modNode && remNodes.length) { |
| 1968 modNode.data += s; | 1968 modNode.data += s; |
| 1969 cleanupNodes(remNodes); | 1969 cleanupNodes(remNodes); |
| 1970 } | 1970 } |
| 1971 remNodes = []; | 1971 remNodes = []; |
| 1972 s = ""; | 1972 s = ""; |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2292 if (this.parentNode) this.parentNode.insertBefore(newTextNode, this.nextSi
bling); | 2292 if (this.parentNode) this.parentNode.insertBefore(newTextNode, this.nextSi
bling); |
| 2293 return newTextNode; | 2293 return newTextNode; |
| 2294 } | 2294 } |
| 2295 }); | 2295 }); |
| 2296 registerWrapper(OriginalText, Text, document.createTextNode("")); | 2296 registerWrapper(OriginalText, Text, document.createTextNode("")); |
| 2297 scope.wrappers.Text = Text; | 2297 scope.wrappers.Text = Text; |
| 2298 })(window.ShadowDOMPolyfill); | 2298 })(window.ShadowDOMPolyfill); |
| 2299 | 2299 |
| 2300 (function(scope) { | 2300 (function(scope) { |
| 2301 "use strict"; | 2301 "use strict"; |
| 2302 var setWrapper = scope.setWrapper; | |
| 2303 var unsafeUnwrap = scope.unsafeUnwrap; | 2302 var unsafeUnwrap = scope.unsafeUnwrap; |
| 2303 var enqueueMutation = scope.enqueueMutation; |
| 2304 function getClass(el) { |
| 2305 return unsafeUnwrap(el).getAttribute("class"); |
| 2306 } |
| 2307 function enqueueClassAttributeChange(el, oldValue) { |
| 2308 enqueueMutation(el, "attributes", { |
| 2309 name: "class", |
| 2310 namespace: null, |
| 2311 oldValue: oldValue |
| 2312 }); |
| 2313 } |
| 2304 function invalidateClass(el) { | 2314 function invalidateClass(el) { |
| 2305 scope.invalidateRendererBasedOnAttribute(el, "class"); | 2315 scope.invalidateRendererBasedOnAttribute(el, "class"); |
| 2306 } | 2316 } |
| 2307 function DOMTokenList(impl, ownerElement) { | 2317 function changeClass(tokenList, method, args) { |
| 2308 setWrapper(impl, this); | 2318 var ownerElement = tokenList.ownerElement_; |
| 2309 this.ownerElement_ = ownerElement; | 2319 if (ownerElement == null) { |
| 2320 return method.apply(tokenList, args); |
| 2321 } |
| 2322 var oldValue = getClass(ownerElement); |
| 2323 var retv = method.apply(tokenList, args); |
| 2324 if (getClass(ownerElement) !== oldValue) { |
| 2325 enqueueClassAttributeChange(ownerElement, oldValue); |
| 2326 invalidateClass(ownerElement); |
| 2327 } |
| 2328 return retv; |
| 2310 } | 2329 } |
| 2311 DOMTokenList.prototype = { | 2330 var oldAdd = DOMTokenList.prototype.add; |
| 2312 constructor: DOMTokenList, | 2331 DOMTokenList.prototype.add = function() { |
| 2313 get length() { | 2332 changeClass(this, oldAdd, arguments); |
| 2314 return unsafeUnwrap(this).length; | |
| 2315 }, | |
| 2316 item: function(index) { | |
| 2317 return unsafeUnwrap(this).item(index); | |
| 2318 }, | |
| 2319 contains: function(token) { | |
| 2320 return unsafeUnwrap(this).contains(token); | |
| 2321 }, | |
| 2322 add: function() { | |
| 2323 unsafeUnwrap(this).add.apply(unsafeUnwrap(this), arguments); | |
| 2324 invalidateClass(this.ownerElement_); | |
| 2325 }, | |
| 2326 remove: function() { | |
| 2327 unsafeUnwrap(this).remove.apply(unsafeUnwrap(this), arguments); | |
| 2328 invalidateClass(this.ownerElement_); | |
| 2329 }, | |
| 2330 toggle: function(token) { | |
| 2331 var rv = unsafeUnwrap(this).toggle.apply(unsafeUnwrap(this), arguments); | |
| 2332 invalidateClass(this.ownerElement_); | |
| 2333 return rv; | |
| 2334 }, | |
| 2335 toString: function() { | |
| 2336 return unsafeUnwrap(this).toString(); | |
| 2337 } | |
| 2338 }; | 2333 }; |
| 2339 scope.wrappers.DOMTokenList = DOMTokenList; | 2334 var oldRemove = DOMTokenList.prototype.remove; |
| 2335 DOMTokenList.prototype.remove = function() { |
| 2336 changeClass(this, oldRemove, arguments); |
| 2337 }; |
| 2338 var oldToggle = DOMTokenList.prototype.toggle; |
| 2339 DOMTokenList.prototype.toggle = function() { |
| 2340 return changeClass(this, oldToggle, arguments); |
| 2341 }; |
| 2340 })(window.ShadowDOMPolyfill); | 2342 })(window.ShadowDOMPolyfill); |
| 2341 | 2343 |
| 2342 (function(scope) { | 2344 (function(scope) { |
| 2343 "use strict"; | 2345 "use strict"; |
| 2344 var ChildNodeInterface = scope.ChildNodeInterface; | 2346 var ChildNodeInterface = scope.ChildNodeInterface; |
| 2345 var GetElementsByInterface = scope.GetElementsByInterface; | 2347 var GetElementsByInterface = scope.GetElementsByInterface; |
| 2346 var Node = scope.wrappers.Node; | 2348 var Node = scope.wrappers.Node; |
| 2347 var DOMTokenList = scope.wrappers.DOMTokenList; | |
| 2348 var ParentNodeInterface = scope.ParentNodeInterface; | 2349 var ParentNodeInterface = scope.ParentNodeInterface; |
| 2349 var SelectorsInterface = scope.SelectorsInterface; | 2350 var SelectorsInterface = scope.SelectorsInterface; |
| 2350 var addWrapNodeListMethod = scope.addWrapNodeListMethod; | 2351 var addWrapNodeListMethod = scope.addWrapNodeListMethod; |
| 2351 var enqueueMutation = scope.enqueueMutation; | 2352 var enqueueMutation = scope.enqueueMutation; |
| 2352 var mixin = scope.mixin; | 2353 var mixin = scope.mixin; |
| 2353 var oneOf = scope.oneOf; | 2354 var oneOf = scope.oneOf; |
| 2354 var registerWrapper = scope.registerWrapper; | 2355 var registerWrapper = scope.registerWrapper; |
| 2355 var unsafeUnwrap = scope.unsafeUnwrap; | 2356 var unsafeUnwrap = scope.unsafeUnwrap; |
| 2356 var wrappers = scope.wrappers; | 2357 var wrappers = scope.wrappers; |
| 2357 var OriginalElement = window.Element; | 2358 var OriginalElement = window.Element; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2400 unsafeUnwrap(this).removeAttribute(name); | 2401 unsafeUnwrap(this).removeAttribute(name); |
| 2401 enqueAttributeChange(this, name, oldValue); | 2402 enqueAttributeChange(this, name, oldValue); |
| 2402 invalidateRendererBasedOnAttribute(this, name); | 2403 invalidateRendererBasedOnAttribute(this, name); |
| 2403 }, | 2404 }, |
| 2404 matches: function(selector) { | 2405 matches: function(selector) { |
| 2405 return originalMatches.call(unsafeUnwrap(this), selector); | 2406 return originalMatches.call(unsafeUnwrap(this), selector); |
| 2406 }, | 2407 }, |
| 2407 get classList() { | 2408 get classList() { |
| 2408 var list = classListTable.get(this); | 2409 var list = classListTable.get(this); |
| 2409 if (!list) { | 2410 if (!list) { |
| 2410 classListTable.set(this, list = new DOMTokenList(unsafeUnwrap(this).clas
sList, this)); | 2411 list = unsafeUnwrap(this).classList; |
| 2412 list.ownerElement_ = this; |
| 2413 classListTable.set(this, list); |
| 2411 } | 2414 } |
| 2412 return list; | 2415 return list; |
| 2413 }, | 2416 }, |
| 2414 get className() { | 2417 get className() { |
| 2415 return unsafeUnwrap(this).className; | 2418 return unsafeUnwrap(this).className; |
| 2416 }, | 2419 }, |
| 2417 set className(v) { | 2420 set className(v) { |
| 2418 this.setAttribute("class", v); | 2421 this.setAttribute("class", v); |
| 2419 }, | 2422 }, |
| 2420 get id() { | 2423 get id() { |
| (...skipping 1583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4004 } | 4007 } |
| 4005 CustomElementConstructor.prototype = prototype; | 4008 CustomElementConstructor.prototype = prototype; |
| 4006 CustomElementConstructor.prototype.constructor = CustomElementConstructor; | 4009 CustomElementConstructor.prototype.constructor = CustomElementConstructor; |
| 4007 scope.constructorTable.set(newPrototype, CustomElementConstructor); | 4010 scope.constructorTable.set(newPrototype, CustomElementConstructor); |
| 4008 scope.nativePrototypeTable.set(prototype, newPrototype); | 4011 scope.nativePrototypeTable.set(prototype, newPrototype); |
| 4009 var nativeConstructor = originalRegisterElement.call(unwrap(this), tagName
, p); | 4012 var nativeConstructor = originalRegisterElement.call(unwrap(this), tagName
, p); |
| 4010 return CustomElementConstructor; | 4013 return CustomElementConstructor; |
| 4011 }; | 4014 }; |
| 4012 forwardMethodsToWrapper([ window.HTMLDocument || window.Document ], [ "regis
terElement" ]); | 4015 forwardMethodsToWrapper([ window.HTMLDocument || window.Document ], [ "regis
terElement" ]); |
| 4013 } | 4016 } |
| 4014 forwardMethodsToWrapper([ window.HTMLBodyElement, window.HTMLDocument || windo
w.Document, window.HTMLHeadElement, window.HTMLHtmlElement ], [ "appendChild", "
compareDocumentPosition", "contains", "getElementsByClassName", "getElementsByTa
gName", "getElementsByTagNameNS", "insertBefore", "querySelector", "querySelecto
rAll", "removeChild", "replaceChild" ].concat(matchesNames)); | 4017 forwardMethodsToWrapper([ window.HTMLBodyElement, window.HTMLDocument || windo
w.Document, window.HTMLHeadElement, window.HTMLHtmlElement ], [ "appendChild", "
compareDocumentPosition", "contains", "getElementsByClassName", "getElementsByTa
gName", "getElementsByTagNameNS", "insertBefore", "querySelector", "querySelecto
rAll", "removeChild", "replaceChild" ]); |
| 4018 forwardMethodsToWrapper([ window.HTMLBodyElement, window.HTMLHeadElement, wind
ow.HTMLHtmlElement ], matchesNames); |
| 4015 forwardMethodsToWrapper([ window.HTMLDocument || window.Document ], [ "adoptNo
de", "importNode", "contains", "createComment", "createDocumentFragment", "creat
eElement", "createElementNS", "createEvent", "createEventNS", "createRange", "cr
eateTextNode", "elementFromPoint", "getElementById", "getElementsByName", "getSe
lection" ]); | 4019 forwardMethodsToWrapper([ window.HTMLDocument || window.Document ], [ "adoptNo
de", "importNode", "contains", "createComment", "createDocumentFragment", "creat
eElement", "createElementNS", "createEvent", "createEventNS", "createRange", "cr
eateTextNode", "elementFromPoint", "getElementById", "getElementsByName", "getSe
lection" ]); |
| 4016 mixin(Document.prototype, GetElementsByInterface); | 4020 mixin(Document.prototype, GetElementsByInterface); |
| 4017 mixin(Document.prototype, ParentNodeInterface); | 4021 mixin(Document.prototype, ParentNodeInterface); |
| 4018 mixin(Document.prototype, SelectorsInterface); | 4022 mixin(Document.prototype, SelectorsInterface); |
| 4019 mixin(Document.prototype, { | 4023 mixin(Document.prototype, { |
| 4020 get implementation() { | 4024 get implementation() { |
| 4021 var implementation = implementationTable.get(this); | 4025 var implementation = implementationTable.get(this); |
| 4022 if (implementation) return implementation; | 4026 if (implementation) return implementation; |
| 4023 implementation = new DOMImplementation(unwrap(this).implementation); | 4027 implementation = new DOMImplementation(unwrap(this).implementation); |
| 4024 implementationTable.set(this, implementation); | 4028 implementationTable.set(this, implementation); |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4239 if (!nativeConstructor) return; | 4243 if (!nativeConstructor) return; |
| 4240 var element = document.createElement(tagName); | 4244 var element = document.createElement(tagName); |
| 4241 var wrapperConstructor = element.constructor; | 4245 var wrapperConstructor = element.constructor; |
| 4242 window[nativeConstructorName] = wrapperConstructor; | 4246 window[nativeConstructorName] = wrapperConstructor; |
| 4243 } | 4247 } |
| 4244 Object.keys(elements).forEach(overrideConstructor); | 4248 Object.keys(elements).forEach(overrideConstructor); |
| 4245 Object.getOwnPropertyNames(scope.wrappers).forEach(function(name) { | 4249 Object.getOwnPropertyNames(scope.wrappers).forEach(function(name) { |
| 4246 window[name] = scope.wrappers[name]; | 4250 window[name] = scope.wrappers[name]; |
| 4247 }); | 4251 }); |
| 4248 })(window.ShadowDOMPolyfill); | 4252 })(window.ShadowDOMPolyfill); |
| OLD | NEW |