| OLD | NEW |
| 1 /** | 1 /** |
| 2 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. | 2 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
| 3 * This code may only be used under the BSD style license found at http://polyme
r.github.io/LICENSE.txt | 3 * This code may only be used under the BSD style license found at http://polyme
r.github.io/LICENSE.txt |
| 4 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.
txt | 4 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.
txt |
| 5 * The complete set of contributors may be found at http://polymer.github.io/CON
TRIBUTORS.txt | 5 * The complete set of contributors may be found at http://polymer.github.io/CON
TRIBUTORS.txt |
| 6 * Code distributed by Google as part of the polymer project is also | 6 * Code distributed by Google as part of the polymer project is also |
| 7 * subject to an additional IP rights grant found at http://polymer.github.io/PA
TENTS.txt | 7 * subject to an additional IP rights grant found at http://polymer.github.io/PA
TENTS.txt |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 window.Platform = window.Platform || {}; | 10 window.Platform = window.Platform || {}; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 entry[1] = value; | 88 entry[1] = value; |
| 89 else | 89 else |
| 90 defineProperty(key, this.name, {value: [key, value], writable: true}); | 90 defineProperty(key, this.name, {value: [key, value], writable: true}); |
| 91 }, | 91 }, |
| 92 get: function(key) { | 92 get: function(key) { |
| 93 var entry; | 93 var entry; |
| 94 return (entry = key[this.name]) && entry[0] === key ? | 94 return (entry = key[this.name]) && entry[0] === key ? |
| 95 entry[1] : undefined; | 95 entry[1] : undefined; |
| 96 }, | 96 }, |
| 97 delete: function(key) { | 97 delete: function(key) { |
| 98 this.set(key, undefined); | 98 var entry = key[this.name]; |
| 99 if (!entry) return false; |
| 100 var hasValue = entry[0] === key; |
| 101 entry[0] = entry[1] = undefined; |
| 102 return hasValue; |
| 103 }, |
| 104 has: function(key) { |
| 105 var entry = key[this.name]; |
| 106 if (!entry) return false; |
| 107 return entry[0] === key; |
| 99 } | 108 } |
| 100 }; | 109 }; |
| 101 | 110 |
| 102 window.WeakMap = WeakMap; | 111 window.WeakMap = WeakMap; |
| 103 })(); | 112 })(); |
| 104 } | 113 } |
| 105 | 114 |
| 106 // Copyright 2012 Google Inc. | 115 // Copyright 2012 Google Inc. |
| 107 // | 116 // |
| 108 // Licensed under the Apache License, Version 2.0 (the "License"); | 117 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 109 // you may not use this file except in compliance with the License. | 118 // you may not use this file except in compliance with the License. |
| 110 // You may obtain a copy of the License at | 119 // You may obtain a copy of the License at |
| 111 // | 120 // |
| 112 // http://www.apache.org/licenses/LICENSE-2.0 | 121 // http://www.apache.org/licenses/LICENSE-2.0 |
| 113 // | 122 // |
| 114 // Unless required by applicable law or agreed to in writing, software | 123 // Unless required by applicable law or agreed to in writing, software |
| 115 // distributed under the License is distributed on an "AS IS" BASIS, | 124 // distributed under the License is distributed on an "AS IS" BASIS, |
| 116 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 125 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 117 // See the License for the specific language governing permissions and | 126 // See the License for the specific language governing permissions and |
| 118 // limitations under the License. | 127 // limitations under the License. |
| 119 | 128 |
| 120 (function(global) { | 129 (function(global) { |
| 121 'use strict'; | 130 'use strict'; |
| 122 | 131 |
| 132 var testingExposeCycleCount = global.testingExposeCycleCount; |
| 133 |
| 123 // Detect and do basic sanity checking on Object/Array.observe. | 134 // Detect and do basic sanity checking on Object/Array.observe. |
| 124 function detectObjectObserve() { | 135 function detectObjectObserve() { |
| 125 if (typeof Object.observe !== 'function' || | 136 if (typeof Object.observe !== 'function' || |
| 126 typeof Array.observe !== 'function') { | 137 typeof Array.observe !== 'function') { |
| 127 return false; | 138 return false; |
| 128 } | 139 } |
| 129 | 140 |
| 130 var records = []; | 141 var records = []; |
| 131 | 142 |
| 132 function callback(recs) { | 143 function callback(recs) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 163 | 174 |
| 164 var hasObserve = detectObjectObserve(); | 175 var hasObserve = detectObjectObserve(); |
| 165 | 176 |
| 166 function detectEval() { | 177 function detectEval() { |
| 167 // Don't test for eval if we're running in a Chrome App environment. | 178 // Don't test for eval if we're running in a Chrome App environment. |
| 168 // We check for APIs set that only exist in a Chrome App context. | 179 // We check for APIs set that only exist in a Chrome App context. |
| 169 if (typeof chrome !== 'undefined' && chrome.app && chrome.app.runtime) { | 180 if (typeof chrome !== 'undefined' && chrome.app && chrome.app.runtime) { |
| 170 return false; | 181 return false; |
| 171 } | 182 } |
| 172 | 183 |
| 184 // Firefox OS Apps do not allow eval. This feature detection is very hacky |
| 185 // but even if some other platform adds support for this function this code |
| 186 // will continue to work. |
| 187 if (navigator.getDeviceStorage) { |
| 188 return false; |
| 189 } |
| 190 |
| 173 try { | 191 try { |
| 174 var f = new Function('', 'return true;'); | 192 var f = new Function('', 'return true;'); |
| 175 return f(); | 193 return f(); |
| 176 } catch (ex) { | 194 } catch (ex) { |
| 177 return false; | 195 return false; |
| 178 } | 196 } |
| 179 } | 197 } |
| 180 | 198 |
| 181 var hasEval = detectEval(); | 199 var hasEval = detectEval(); |
| 182 | 200 |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 invalidPath.valid = false; | 555 invalidPath.valid = false; |
| 538 invalidPath.getValueFrom = invalidPath.setValueFrom = function() {}; | 556 invalidPath.getValueFrom = invalidPath.setValueFrom = function() {}; |
| 539 | 557 |
| 540 var MAX_DIRTY_CHECK_CYCLES = 1000; | 558 var MAX_DIRTY_CHECK_CYCLES = 1000; |
| 541 | 559 |
| 542 function dirtyCheck(observer) { | 560 function dirtyCheck(observer) { |
| 543 var cycles = 0; | 561 var cycles = 0; |
| 544 while (cycles < MAX_DIRTY_CHECK_CYCLES && observer.check_()) { | 562 while (cycles < MAX_DIRTY_CHECK_CYCLES && observer.check_()) { |
| 545 cycles++; | 563 cycles++; |
| 546 } | 564 } |
| 547 if (global.testingExposeCycleCount) | 565 if (testingExposeCycleCount) |
| 548 global.dirtyCheckCycleCount = cycles; | 566 global.dirtyCheckCycleCount = cycles; |
| 549 | 567 |
| 550 return cycles > 0; | 568 return cycles > 0; |
| 551 } | 569 } |
| 552 | 570 |
| 553 function objectIsEmpty(object) { | 571 function objectIsEmpty(object) { |
| 554 for (var prop in object) | 572 for (var prop in object) |
| 555 return false; | 573 return false; |
| 556 return true; | 574 return true; |
| 557 } | 575 } |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 936 | 954 |
| 937 if (observer.check_()) | 955 if (observer.check_()) |
| 938 anyChanged = true; | 956 anyChanged = true; |
| 939 | 957 |
| 940 allObservers.push(observer); | 958 allObservers.push(observer); |
| 941 } | 959 } |
| 942 if (runEOMTasks()) | 960 if (runEOMTasks()) |
| 943 anyChanged = true; | 961 anyChanged = true; |
| 944 } while (cycles < MAX_DIRTY_CHECK_CYCLES && anyChanged); | 962 } while (cycles < MAX_DIRTY_CHECK_CYCLES && anyChanged); |
| 945 | 963 |
| 946 if (global.testingExposeCycleCount) | 964 if (testingExposeCycleCount) |
| 947 global.dirtyCheckCycleCount = cycles; | 965 global.dirtyCheckCycleCount = cycles; |
| 948 | 966 |
| 949 runningMicrotaskCheckpoint = false; | 967 runningMicrotaskCheckpoint = false; |
| 950 }; | 968 }; |
| 951 | 969 |
| 952 if (collectObservers) { | 970 if (collectObservers) { |
| 953 global.Platform.clearObservers = function() { | 971 global.Platform.clearObservers = function() { |
| 954 allObservers = []; | 972 allObservers = []; |
| 955 }; | 973 }; |
| 956 } | 974 } |
| (...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1838 var nativePrototypeTable = new WeakMap(); | 1856 var nativePrototypeTable = new WeakMap(); |
| 1839 var wrappers = Object.create(null); | 1857 var wrappers = Object.create(null); |
| 1840 | 1858 |
| 1841 function detectEval() { | 1859 function detectEval() { |
| 1842 // Don't test for eval if we're running in a Chrome App environment. | 1860 // Don't test for eval if we're running in a Chrome App environment. |
| 1843 // We check for APIs set that only exist in a Chrome App context. | 1861 // We check for APIs set that only exist in a Chrome App context. |
| 1844 if (typeof chrome !== 'undefined' && chrome.app && chrome.app.runtime) { | 1862 if (typeof chrome !== 'undefined' && chrome.app && chrome.app.runtime) { |
| 1845 return false; | 1863 return false; |
| 1846 } | 1864 } |
| 1847 | 1865 |
| 1866 // Firefox OS Apps do not allow eval. This feature detection is very hacky |
| 1867 // but even if some other platform adds support for this function this code |
| 1868 // will continue to work. |
| 1869 if (navigator.getDeviceStorage) { |
| 1870 return false; |
| 1871 } |
| 1872 |
| 1848 try { | 1873 try { |
| 1849 var f = new Function('return true;'); | 1874 var f = new Function('return true;'); |
| 1850 return f(); | 1875 return f(); |
| 1851 } catch (ex) { | 1876 } catch (ex) { |
| 1852 return false; | 1877 return false; |
| 1853 } | 1878 } |
| 1854 } | 1879 } |
| 1855 | 1880 |
| 1856 var hasEval = detectEval(); | 1881 var hasEval = detectEval(); |
| 1857 | 1882 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1949 }; | 1974 }; |
| 1950 | 1975 |
| 1951 function isEventHandlerName(name) { | 1976 function isEventHandlerName(name) { |
| 1952 return /^on[a-z]+$/.test(name); | 1977 return /^on[a-z]+$/.test(name); |
| 1953 } | 1978 } |
| 1954 | 1979 |
| 1955 function isIdentifierName(name) { | 1980 function isIdentifierName(name) { |
| 1956 return /^\w[a-zA-Z_0-9]*$/.test(name); | 1981 return /^\w[a-zA-Z_0-9]*$/.test(name); |
| 1957 } | 1982 } |
| 1958 | 1983 |
| 1984 // The name of the implementation property is intentionally hard to |
| 1985 // remember. Unfortunately, browsers are slower doing obj[expr] than |
| 1986 // obj.foo so we resort to repeat this ugly name. This ugly name is never |
| 1987 // used outside of this file though. |
| 1988 |
| 1959 function getGetter(name) { | 1989 function getGetter(name) { |
| 1960 return hasEval && isIdentifierName(name) ? | 1990 return hasEval && isIdentifierName(name) ? |
| 1961 new Function('return this.impl.' + name) : | 1991 new Function('return this.__impl4cf1e782hg__.' + name) : |
| 1962 function() { return this.impl[name]; }; | 1992 function() { return this.__impl4cf1e782hg__[name]; }; |
| 1963 } | 1993 } |
| 1964 | 1994 |
| 1965 function getSetter(name) { | 1995 function getSetter(name) { |
| 1966 return hasEval && isIdentifierName(name) ? | 1996 return hasEval && isIdentifierName(name) ? |
| 1967 new Function('v', 'this.impl.' + name + ' = v') : | 1997 new Function('v', 'this.__impl4cf1e782hg__.' + name + ' = v') : |
| 1968 function(v) { this.impl[name] = v; }; | 1998 function(v) { this.__impl4cf1e782hg__[name] = v; }; |
| 1969 } | 1999 } |
| 1970 | 2000 |
| 1971 function getMethod(name) { | 2001 function getMethod(name) { |
| 1972 return hasEval && isIdentifierName(name) ? | 2002 return hasEval && isIdentifierName(name) ? |
| 1973 new Function('return this.impl.' + name + | 2003 new Function('return this.__impl4cf1e782hg__.' + name + |
| 1974 '.apply(this.impl, arguments)') : | 2004 '.apply(this.__impl4cf1e782hg__, arguments)') : |
| 1975 function() { return this.impl[name].apply(this.impl, arguments); }; | 2005 function() { |
| 2006 return this.__impl4cf1e782hg__[name].apply( |
| 2007 this.__impl4cf1e782hg__, arguments); |
| 2008 }; |
| 1976 } | 2009 } |
| 1977 | 2010 |
| 1978 function getDescriptor(source, name) { | 2011 function getDescriptor(source, name) { |
| 1979 try { | 2012 try { |
| 1980 return Object.getOwnPropertyDescriptor(source, name); | 2013 return Object.getOwnPropertyDescriptor(source, name); |
| 1981 } catch (ex) { | 2014 } catch (ex) { |
| 1982 // JSC and V8 both use data properties instead of accessors which can | 2015 // JSC and V8 both use data properties instead of accessors which can |
| 1983 // cause getting the property desciptor to throw an exception. | 2016 // cause getting the property desciptor to throw an exception. |
| 1984 // https://bugs.webkit.org/show_bug.cgi?id=49739 | 2017 // https://bugs.webkit.org/show_bug.cgi?id=49739 |
| 1985 return dummyDescriptor; | 2018 return dummyDescriptor; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2086 function GeneratedWrapper(node) { | 2119 function GeneratedWrapper(node) { |
| 2087 superWrapperConstructor.call(this, node); | 2120 superWrapperConstructor.call(this, node); |
| 2088 } | 2121 } |
| 2089 var p = Object.create(superWrapperConstructor.prototype); | 2122 var p = Object.create(superWrapperConstructor.prototype); |
| 2090 p.constructor = GeneratedWrapper; | 2123 p.constructor = GeneratedWrapper; |
| 2091 GeneratedWrapper.prototype = p; | 2124 GeneratedWrapper.prototype = p; |
| 2092 | 2125 |
| 2093 return GeneratedWrapper; | 2126 return GeneratedWrapper; |
| 2094 } | 2127 } |
| 2095 | 2128 |
| 2096 var OriginalDOMImplementation = window.DOMImplementation; | |
| 2097 var OriginalEventTarget = window.EventTarget; | |
| 2098 var OriginalEvent = window.Event; | |
| 2099 var OriginalNode = window.Node; | |
| 2100 var OriginalWindow = window.Window; | |
| 2101 var OriginalRange = window.Range; | |
| 2102 var OriginalCanvasRenderingContext2D = window.CanvasRenderingContext2D; | |
| 2103 var OriginalWebGLRenderingContext = window.WebGLRenderingContext; | |
| 2104 var OriginalSVGElementInstance = window.SVGElementInstance; | |
| 2105 | |
| 2106 function isWrapper(object) { | 2129 function isWrapper(object) { |
| 2107 return object instanceof wrappers.EventTarget || | 2130 return object && object.__impl4cf1e782hg__; |
| 2108 object instanceof wrappers.Event || | |
| 2109 object instanceof wrappers.Range || | |
| 2110 object instanceof wrappers.DOMImplementation || | |
| 2111 object instanceof wrappers.CanvasRenderingContext2D || | |
| 2112 wrappers.WebGLRenderingContext && | |
| 2113 object instanceof wrappers.WebGLRenderingContext; | |
| 2114 } | 2131 } |
| 2115 | 2132 |
| 2116 function isNative(object) { | 2133 function isNative(object) { |
| 2117 return OriginalEventTarget && object instanceof OriginalEventTarget || | 2134 return !isWrapper(object); |
| 2118 object instanceof OriginalNode || | |
| 2119 object instanceof OriginalEvent || | |
| 2120 object instanceof OriginalWindow || | |
| 2121 object instanceof OriginalRange || | |
| 2122 object instanceof OriginalDOMImplementation || | |
| 2123 object instanceof OriginalCanvasRenderingContext2D || | |
| 2124 OriginalWebGLRenderingContext && | |
| 2125 object instanceof OriginalWebGLRenderingContext || | |
| 2126 OriginalSVGElementInstance && | |
| 2127 object instanceof OriginalSVGElementInstance; | |
| 2128 } | 2135 } |
| 2129 | 2136 |
| 2130 /** | 2137 /** |
| 2131 * Wraps a node in a WrapperNode. If there already exists a wrapper for the | 2138 * Wraps a node in a WrapperNode. If there already exists a wrapper for the |
| 2132 * |node| that wrapper is returned instead. | 2139 * |node| that wrapper is returned instead. |
| 2133 * @param {Node} node | 2140 * @param {Node} node |
| 2134 * @return {WrapperNode} | 2141 * @return {WrapperNode} |
| 2135 */ | 2142 */ |
| 2136 function wrap(impl) { | 2143 function wrap(impl) { |
| 2137 if (impl === null) | 2144 if (impl === null) |
| 2138 return null; | 2145 return null; |
| 2139 | 2146 |
| 2140 assert(isNative(impl)); | 2147 assert(isNative(impl)); |
| 2141 return impl.polymerWrapper_ || | 2148 return impl.__wrapper8e3dd93a60__ || |
| 2142 (impl.polymerWrapper_ = new (getWrapperConstructor(impl))(impl)); | 2149 (impl.__wrapper8e3dd93a60__ = new (getWrapperConstructor(impl))(impl)); |
| 2143 } | 2150 } |
| 2144 | 2151 |
| 2145 /** | 2152 /** |
| 2146 * Unwraps a wrapper and returns the node it is wrapping. | 2153 * Unwraps a wrapper and returns the node it is wrapping. |
| 2147 * @param {WrapperNode} wrapper | 2154 * @param {WrapperNode} wrapper |
| 2148 * @return {Node} | 2155 * @return {Node} |
| 2149 */ | 2156 */ |
| 2150 function unwrap(wrapper) { | 2157 function unwrap(wrapper) { |
| 2151 if (wrapper === null) | 2158 if (wrapper === null) |
| 2152 return null; | 2159 return null; |
| 2153 assert(isWrapper(wrapper)); | 2160 assert(isWrapper(wrapper)); |
| 2154 return wrapper.impl; | 2161 return wrapper.__impl4cf1e782hg__; |
| 2162 } |
| 2163 |
| 2164 function unsafeUnwrap(wrapper) { |
| 2165 return wrapper.__impl4cf1e782hg__; |
| 2166 } |
| 2167 |
| 2168 function setWrapper(impl, wrapper) { |
| 2169 wrapper.__impl4cf1e782hg__ = impl; |
| 2170 impl.__wrapper8e3dd93a60__ = wrapper; |
| 2155 } | 2171 } |
| 2156 | 2172 |
| 2157 /** | 2173 /** |
| 2158 * Unwraps object if it is a wrapper. | 2174 * Unwraps object if it is a wrapper. |
| 2159 * @param {Object} object | 2175 * @param {Object} object |
| 2160 * @return {Object} The native implementation object. | 2176 * @return {Object} The native implementation object. |
| 2161 */ | 2177 */ |
| 2162 function unwrapIfNeeded(object) { | 2178 function unwrapIfNeeded(object) { |
| 2163 return object && isWrapper(object) ? unwrap(object) : object; | 2179 return object && isWrapper(object) ? unwrap(object) : object; |
| 2164 } | 2180 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2176 * Overrides the current wrapper (if any) for node. | 2192 * Overrides the current wrapper (if any) for node. |
| 2177 * @param {Node} node | 2193 * @param {Node} node |
| 2178 * @param {WrapperNode=} wrapper If left out the wrapper will be created as | 2194 * @param {WrapperNode=} wrapper If left out the wrapper will be created as |
| 2179 * needed next time someone wraps the node. | 2195 * needed next time someone wraps the node. |
| 2180 */ | 2196 */ |
| 2181 function rewrap(node, wrapper) { | 2197 function rewrap(node, wrapper) { |
| 2182 if (wrapper === null) | 2198 if (wrapper === null) |
| 2183 return; | 2199 return; |
| 2184 assert(isNative(node)); | 2200 assert(isNative(node)); |
| 2185 assert(wrapper === undefined || isWrapper(wrapper)); | 2201 assert(wrapper === undefined || isWrapper(wrapper)); |
| 2186 node.polymerWrapper_ = wrapper; | 2202 node.__wrapper8e3dd93a60__ = wrapper; |
| 2187 } | 2203 } |
| 2188 | 2204 |
| 2189 var getterDescriptor = { | 2205 var getterDescriptor = { |
| 2190 get: undefined, | 2206 get: undefined, |
| 2191 configurable: true, | 2207 configurable: true, |
| 2192 enumerable: true | 2208 enumerable: true |
| 2193 }; | 2209 }; |
| 2194 | 2210 |
| 2195 function defineGetter(constructor, name, getter) { | 2211 function defineGetter(constructor, name, getter) { |
| 2196 getterDescriptor.get = getter; | 2212 getterDescriptor.get = getter; |
| 2197 defineProperty(constructor.prototype, name, getterDescriptor); | 2213 defineProperty(constructor.prototype, name, getterDescriptor); |
| 2198 } | 2214 } |
| 2199 | 2215 |
| 2200 function defineWrapGetter(constructor, name) { | 2216 function defineWrapGetter(constructor, name) { |
| 2201 defineGetter(constructor, name, function() { | 2217 defineGetter(constructor, name, function() { |
| 2202 return wrap(this.impl[name]); | 2218 return wrap(this.__impl4cf1e782hg__[name]); |
| 2203 }); | 2219 }); |
| 2204 } | 2220 } |
| 2205 | 2221 |
| 2206 /** | 2222 /** |
| 2207 * Forwards existing methods on the native object to the wrapper methods. | 2223 * Forwards existing methods on the native object to the wrapper methods. |
| 2208 * This does not wrap any of the arguments or the return value since the | 2224 * This does not wrap any of the arguments or the return value since the |
| 2209 * wrapper implementation already takes care of that. | 2225 * wrapper implementation already takes care of that. |
| 2210 * @param {Array.<Function>} constructors | 2226 * @param {Array.<Function>} constructors |
| 2211 * @parem {Array.<string>} names | 2227 * @parem {Array.<string>} names |
| 2212 */ | 2228 */ |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2227 scope.defineWrapGetter = defineWrapGetter; | 2243 scope.defineWrapGetter = defineWrapGetter; |
| 2228 scope.forwardMethodsToWrapper = forwardMethodsToWrapper; | 2244 scope.forwardMethodsToWrapper = forwardMethodsToWrapper; |
| 2229 scope.isWrapper = isWrapper; | 2245 scope.isWrapper = isWrapper; |
| 2230 scope.isWrapperFor = isWrapperFor; | 2246 scope.isWrapperFor = isWrapperFor; |
| 2231 scope.mixin = mixin; | 2247 scope.mixin = mixin; |
| 2232 scope.nativePrototypeTable = nativePrototypeTable; | 2248 scope.nativePrototypeTable = nativePrototypeTable; |
| 2233 scope.oneOf = oneOf; | 2249 scope.oneOf = oneOf; |
| 2234 scope.registerObject = registerObject; | 2250 scope.registerObject = registerObject; |
| 2235 scope.registerWrapper = register; | 2251 scope.registerWrapper = register; |
| 2236 scope.rewrap = rewrap; | 2252 scope.rewrap = rewrap; |
| 2253 scope.setWrapper = setWrapper; |
| 2254 scope.unsafeUnwrap = unsafeUnwrap; |
| 2237 scope.unwrap = unwrap; | 2255 scope.unwrap = unwrap; |
| 2238 scope.unwrapIfNeeded = unwrapIfNeeded; | 2256 scope.unwrapIfNeeded = unwrapIfNeeded; |
| 2239 scope.wrap = wrap; | 2257 scope.wrap = wrap; |
| 2240 scope.wrapIfNeeded = wrapIfNeeded; | 2258 scope.wrapIfNeeded = wrapIfNeeded; |
| 2241 scope.wrappers = wrappers; | 2259 scope.wrappers = wrappers; |
| 2242 | 2260 |
| 2243 })(window.ShadowDOMPolyfill); | 2261 })(window.ShadowDOMPolyfill); |
| 2244 | 2262 |
| 2245 /* | 2263 /* |
| 2246 * Copyright 2013 The Polymer Authors. All rights reserved. | 2264 * Copyright 2013 The Polymer Authors. All rights reserved. |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2542 this.callback_ = callback; | 2560 this.callback_ = callback; |
| 2543 this.nodes_ = []; | 2561 this.nodes_ = []; |
| 2544 this.records_ = []; | 2562 this.records_ = []; |
| 2545 this.uid_ = ++uidCounter; | 2563 this.uid_ = ++uidCounter; |
| 2546 | 2564 |
| 2547 // This will leak. There is no way to implement this without WeakRefs :'( | 2565 // This will leak. There is no way to implement this without WeakRefs :'( |
| 2548 globalMutationObservers.push(this); | 2566 globalMutationObservers.push(this); |
| 2549 } | 2567 } |
| 2550 | 2568 |
| 2551 MutationObserver.prototype = { | 2569 MutationObserver.prototype = { |
| 2570 constructor: MutationObserver, |
| 2571 |
| 2552 // http://dom.spec.whatwg.org/#dom-mutationobserver-observe | 2572 // http://dom.spec.whatwg.org/#dom-mutationobserver-observe |
| 2553 observe: function(target, options) { | 2573 observe: function(target, options) { |
| 2554 target = wrapIfNeeded(target); | 2574 target = wrapIfNeeded(target); |
| 2555 | 2575 |
| 2556 var newOptions = new MutationObserverOptions(options); | 2576 var newOptions = new MutationObserverOptions(options); |
| 2557 | 2577 |
| 2558 // 6. | 2578 // 6. |
| 2559 var registration; | 2579 var registration; |
| 2560 var registrations = registrationsTable.get(target); | 2580 var registrations = registrationsTable.get(target); |
| 2561 if (!registrations) | 2581 if (!registrations) |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2751 // Use of this source code is goverened by a BSD-style | 2771 // Use of this source code is goverened by a BSD-style |
| 2752 // license that can be found in the LICENSE file. | 2772 // license that can be found in the LICENSE file. |
| 2753 | 2773 |
| 2754 (function(scope) { | 2774 (function(scope) { |
| 2755 'use strict'; | 2775 'use strict'; |
| 2756 | 2776 |
| 2757 var forwardMethodsToWrapper = scope.forwardMethodsToWrapper; | 2777 var forwardMethodsToWrapper = scope.forwardMethodsToWrapper; |
| 2758 var getTreeScope = scope.getTreeScope; | 2778 var getTreeScope = scope.getTreeScope; |
| 2759 var mixin = scope.mixin; | 2779 var mixin = scope.mixin; |
| 2760 var registerWrapper = scope.registerWrapper; | 2780 var registerWrapper = scope.registerWrapper; |
| 2781 var setWrapper = scope.setWrapper; |
| 2782 var unsafeUnwrap = scope.unsafeUnwrap; |
| 2761 var unwrap = scope.unwrap; | 2783 var unwrap = scope.unwrap; |
| 2762 var wrap = scope.wrap; | 2784 var wrap = scope.wrap; |
| 2763 var wrappers = scope.wrappers; | 2785 var wrappers = scope.wrappers; |
| 2764 | 2786 |
| 2765 var wrappedFuns = new WeakMap(); | 2787 var wrappedFuns = new WeakMap(); |
| 2766 var listenersTable = new WeakMap(); | 2788 var listenersTable = new WeakMap(); |
| 2767 var handledEventsTable = new WeakMap(); | 2789 var handledEventsTable = new WeakMap(); |
| 2768 var currentlyDispatchingEvents = new WeakMap(); | 2790 var currentlyDispatchingEvents = new WeakMap(); |
| 2769 var targetTable = new WeakMap(); | 2791 var targetTable = new WeakMap(); |
| 2770 var currentTargetTable = new WeakMap(); | 2792 var currentTargetTable = new WeakMap(); |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3205 | 3227 |
| 3206 /** | 3228 /** |
| 3207 * Creates a new Event wrapper or wraps an existin native Event object. | 3229 * Creates a new Event wrapper or wraps an existin native Event object. |
| 3208 * @param {string|Event} type | 3230 * @param {string|Event} type |
| 3209 * @param {Object=} options | 3231 * @param {Object=} options |
| 3210 * @constructor | 3232 * @constructor |
| 3211 */ | 3233 */ |
| 3212 function Event(type, options) { | 3234 function Event(type, options) { |
| 3213 if (type instanceof OriginalEvent) { | 3235 if (type instanceof OriginalEvent) { |
| 3214 var impl = type; | 3236 var impl = type; |
| 3215 if (!OriginalBeforeUnloadEvent && impl.type === 'beforeunload') | 3237 if (!OriginalBeforeUnloadEvent && impl.type === 'beforeunload') { |
| 3216 return new BeforeUnloadEvent(impl); | 3238 return new BeforeUnloadEvent(impl); |
| 3217 this.impl = impl; | 3239 } |
| 3240 setWrapper(impl, this); |
| 3218 } else { | 3241 } else { |
| 3219 return wrap(constructEvent(OriginalEvent, 'Event', type, options)); | 3242 return wrap(constructEvent(OriginalEvent, 'Event', type, options)); |
| 3220 } | 3243 } |
| 3221 } | 3244 } |
| 3222 Event.prototype = { | 3245 Event.prototype = { |
| 3223 get target() { | 3246 get target() { |
| 3224 return targetTable.get(this); | 3247 return targetTable.get(this); |
| 3225 }, | 3248 }, |
| 3226 get currentTarget() { | 3249 get currentTarget() { |
| 3227 return currentTargetTable.get(this); | 3250 return currentTargetTable.get(this); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 3251 return options; | 3274 return options; |
| 3252 return Object.create(options, { | 3275 return Object.create(options, { |
| 3253 relatedTarget: {value: unwrap(options.relatedTarget)} | 3276 relatedTarget: {value: unwrap(options.relatedTarget)} |
| 3254 }); | 3277 }); |
| 3255 } | 3278 } |
| 3256 | 3279 |
| 3257 function registerGenericEvent(name, SuperEvent, prototype) { | 3280 function registerGenericEvent(name, SuperEvent, prototype) { |
| 3258 var OriginalEvent = window[name]; | 3281 var OriginalEvent = window[name]; |
| 3259 var GenericEvent = function(type, options) { | 3282 var GenericEvent = function(type, options) { |
| 3260 if (type instanceof OriginalEvent) | 3283 if (type instanceof OriginalEvent) |
| 3261 this.impl = type; | 3284 setWrapper(type, this); |
| 3262 else | 3285 else |
| 3263 return wrap(constructEvent(OriginalEvent, name, type, options)); | 3286 return wrap(constructEvent(OriginalEvent, name, type, options)); |
| 3264 }; | 3287 }; |
| 3265 GenericEvent.prototype = Object.create(SuperEvent.prototype); | 3288 GenericEvent.prototype = Object.create(SuperEvent.prototype); |
| 3266 if (prototype) | 3289 if (prototype) |
| 3267 mixin(GenericEvent.prototype, prototype); | 3290 mixin(GenericEvent.prototype, prototype); |
| 3268 if (OriginalEvent) { | 3291 if (OriginalEvent) { |
| 3269 // - Old versions of Safari fails on new FocusEvent (and others?). | 3292 // - Old versions of Safari fails on new FocusEvent (and others?). |
| 3270 // - IE does not support event constructors. | 3293 // - IE does not support event constructors. |
| 3271 // - createEvent('FocusEvent') throws in Firefox. | 3294 // - createEvent('FocusEvent') throws in Firefox. |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3382 // Safari 7 does not yet have BeforeUnloadEvent. | 3405 // Safari 7 does not yet have BeforeUnloadEvent. |
| 3383 // https://bugs.webkit.org/show_bug.cgi?id=120849 | 3406 // https://bugs.webkit.org/show_bug.cgi?id=120849 |
| 3384 var OriginalBeforeUnloadEvent = window.BeforeUnloadEvent; | 3407 var OriginalBeforeUnloadEvent = window.BeforeUnloadEvent; |
| 3385 | 3408 |
| 3386 function BeforeUnloadEvent(impl) { | 3409 function BeforeUnloadEvent(impl) { |
| 3387 Event.call(this, impl); | 3410 Event.call(this, impl); |
| 3388 } | 3411 } |
| 3389 BeforeUnloadEvent.prototype = Object.create(Event.prototype); | 3412 BeforeUnloadEvent.prototype = Object.create(Event.prototype); |
| 3390 mixin(BeforeUnloadEvent.prototype, { | 3413 mixin(BeforeUnloadEvent.prototype, { |
| 3391 get returnValue() { | 3414 get returnValue() { |
| 3392 return this.impl.returnValue; | 3415 return unsafeUnwrap(this).returnValue; |
| 3393 }, | 3416 }, |
| 3394 set returnValue(v) { | 3417 set returnValue(v) { |
| 3395 this.impl.returnValue = v; | 3418 unsafeUnwrap(this).returnValue = v; |
| 3396 } | 3419 } |
| 3397 }); | 3420 }); |
| 3398 | 3421 |
| 3399 if (OriginalBeforeUnloadEvent) | 3422 if (OriginalBeforeUnloadEvent) |
| 3400 registerWrapper(OriginalBeforeUnloadEvent, BeforeUnloadEvent); | 3423 registerWrapper(OriginalBeforeUnloadEvent, BeforeUnloadEvent); |
| 3401 | 3424 |
| 3402 function isValidListener(fun) { | 3425 function isValidListener(fun) { |
| 3403 if (typeof fun === 'function') | 3426 if (typeof fun === 'function') |
| 3404 return true; | 3427 return true; |
| 3405 return fun && fun.handleEvent; | 3428 return fun && fun.handleEvent; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 3422 } | 3445 } |
| 3423 | 3446 |
| 3424 var OriginalEventTarget = window.EventTarget; | 3447 var OriginalEventTarget = window.EventTarget; |
| 3425 | 3448 |
| 3426 /** | 3449 /** |
| 3427 * This represents a wrapper for an EventTarget. | 3450 * This represents a wrapper for an EventTarget. |
| 3428 * @param {!EventTarget} impl The original event target. | 3451 * @param {!EventTarget} impl The original event target. |
| 3429 * @constructor | 3452 * @constructor |
| 3430 */ | 3453 */ |
| 3431 function EventTarget(impl) { | 3454 function EventTarget(impl) { |
| 3432 this.impl = impl; | 3455 setWrapper(impl, this); |
| 3433 } | 3456 } |
| 3434 | 3457 |
| 3435 // Node and Window have different internal type checks in WebKit so we cannot | 3458 // Node and Window have different internal type checks in WebKit so we cannot |
| 3436 // use the same method as the original function. | 3459 // use the same method as the original function. |
| 3437 var methodNames = [ | 3460 var methodNames = [ |
| 3438 'addEventListener', | 3461 'addEventListener', |
| 3439 'removeEventListener', | 3462 'removeEventListener', |
| 3440 'dispatchEvent' | 3463 'dispatchEvent' |
| 3441 ]; | 3464 ]; |
| 3442 | 3465 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3560 | 3583 |
| 3561 function wrapEventTargetMethods(constructors) { | 3584 function wrapEventTargetMethods(constructors) { |
| 3562 forwardMethodsToWrapper(constructors, methodNames); | 3585 forwardMethodsToWrapper(constructors, methodNames); |
| 3563 } | 3586 } |
| 3564 | 3587 |
| 3565 var originalElementFromPoint = document.elementFromPoint; | 3588 var originalElementFromPoint = document.elementFromPoint; |
| 3566 | 3589 |
| 3567 function elementFromPoint(self, document, x, y) { | 3590 function elementFromPoint(self, document, x, y) { |
| 3568 scope.renderAllPending(); | 3591 scope.renderAllPending(); |
| 3569 | 3592 |
| 3570 var element = wrap(originalElementFromPoint.call(document.impl, x, y)); | 3593 var element = |
| 3594 wrap(originalElementFromPoint.call(unsafeUnwrap(document), x, y)); |
| 3571 if (!element) | 3595 if (!element) |
| 3572 return null; | 3596 return null; |
| 3573 var path = getEventPath(element, null); | 3597 var path = getEventPath(element, null); |
| 3574 | 3598 |
| 3575 // scope the path to this TreeScope | 3599 // scope the path to this TreeScope |
| 3576 var idx = path.lastIndexOf(self); | 3600 var idx = path.lastIndexOf(self); |
| 3577 if (idx == -1) | 3601 if (idx == -1) |
| 3578 return null; | 3602 return null; |
| 3579 else | 3603 else |
| 3580 path = path.slice(0, idx); | 3604 path = path.slice(0, idx); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3653 * Use of this source code is goverened by a BSD-style | 3677 * Use of this source code is goverened by a BSD-style |
| 3654 * license that can be found in the LICENSE file. | 3678 * license that can be found in the LICENSE file. |
| 3655 */ | 3679 */ |
| 3656 | 3680 |
| 3657 (function(scope) { | 3681 (function(scope) { |
| 3658 'use strict'; | 3682 'use strict'; |
| 3659 | 3683 |
| 3660 var UIEvent = scope.wrappers.UIEvent; | 3684 var UIEvent = scope.wrappers.UIEvent; |
| 3661 var mixin = scope.mixin; | 3685 var mixin = scope.mixin; |
| 3662 var registerWrapper = scope.registerWrapper; | 3686 var registerWrapper = scope.registerWrapper; |
| 3663 var unwrap = scope.unwrap; | 3687 var setWrapper = scope.setWrapper; |
| 3688 var unsafeUnwrap = scope.unsafeUnwrap; |
| 3664 var wrap = scope.wrap; | 3689 var wrap = scope.wrap; |
| 3665 | 3690 |
| 3666 // TouchEvent is WebKit/Blink only. | 3691 // TouchEvent is WebKit/Blink only. |
| 3667 var OriginalTouchEvent = window.TouchEvent; | 3692 var OriginalTouchEvent = window.TouchEvent; |
| 3668 if (!OriginalTouchEvent) | 3693 if (!OriginalTouchEvent) |
| 3669 return; | 3694 return; |
| 3670 | 3695 |
| 3671 var nativeEvent; | 3696 var nativeEvent; |
| 3672 try { | 3697 try { |
| 3673 nativeEvent = document.createEvent('TouchEvent'); | 3698 nativeEvent = document.createEvent('TouchEvent'); |
| 3674 } catch (ex) { | 3699 } catch (ex) { |
| 3675 // In Chrome creating a TouchEvent fails if the feature is not turned on | 3700 // In Chrome creating a TouchEvent fails if the feature is not turned on |
| 3676 // which it isn't on desktop Chrome. | 3701 // which it isn't on desktop Chrome. |
| 3677 return; | 3702 return; |
| 3678 } | 3703 } |
| 3679 | 3704 |
| 3680 var nonEnumDescriptor = {enumerable: false}; | 3705 var nonEnumDescriptor = {enumerable: false}; |
| 3681 | 3706 |
| 3682 function nonEnum(obj, prop) { | 3707 function nonEnum(obj, prop) { |
| 3683 Object.defineProperty(obj, prop, nonEnumDescriptor); | 3708 Object.defineProperty(obj, prop, nonEnumDescriptor); |
| 3684 } | 3709 } |
| 3685 | 3710 |
| 3686 function Touch(impl) { | 3711 function Touch(impl) { |
| 3687 this.impl = impl; | 3712 setWrapper(impl, this); |
| 3688 } | 3713 } |
| 3689 | 3714 |
| 3690 Touch.prototype = { | 3715 Touch.prototype = { |
| 3691 get target() { | 3716 get target() { |
| 3692 return wrap(this.impl.target); | 3717 return wrap(unsafeUnwrap(this).target); |
| 3693 } | 3718 } |
| 3694 }; | 3719 }; |
| 3695 | 3720 |
| 3696 var descr = { | 3721 var descr = { |
| 3697 configurable: true, | 3722 configurable: true, |
| 3698 enumerable: true, | 3723 enumerable: true, |
| 3699 get: null | 3724 get: null |
| 3700 }; | 3725 }; |
| 3701 | 3726 |
| 3702 [ | 3727 [ |
| 3703 'clientX', | 3728 'clientX', |
| 3704 'clientY', | 3729 'clientY', |
| 3705 'screenX', | 3730 'screenX', |
| 3706 'screenY', | 3731 'screenY', |
| 3707 'pageX', | 3732 'pageX', |
| 3708 'pageY', | 3733 'pageY', |
| 3709 'identifier', | 3734 'identifier', |
| 3710 'webkitRadiusX', | 3735 'webkitRadiusX', |
| 3711 'webkitRadiusY', | 3736 'webkitRadiusY', |
| 3712 'webkitRotationAngle', | 3737 'webkitRotationAngle', |
| 3713 'webkitForce' | 3738 'webkitForce' |
| 3714 ].forEach(function(name) { | 3739 ].forEach(function(name) { |
| 3715 descr.get = function() { | 3740 descr.get = function() { |
| 3716 return this.impl[name]; | 3741 return unsafeUnwrap(this)[name]; |
| 3717 }; | 3742 }; |
| 3718 Object.defineProperty(Touch.prototype, name, descr); | 3743 Object.defineProperty(Touch.prototype, name, descr); |
| 3719 }); | 3744 }); |
| 3720 | 3745 |
| 3721 function TouchList() { | 3746 function TouchList() { |
| 3722 this.length = 0; | 3747 this.length = 0; |
| 3723 nonEnum(this, 'length'); | 3748 nonEnum(this, 'length'); |
| 3724 } | 3749 } |
| 3725 | 3750 |
| 3726 TouchList.prototype = { | 3751 TouchList.prototype = { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3739 } | 3764 } |
| 3740 | 3765 |
| 3741 function TouchEvent(impl) { | 3766 function TouchEvent(impl) { |
| 3742 UIEvent.call(this, impl); | 3767 UIEvent.call(this, impl); |
| 3743 } | 3768 } |
| 3744 | 3769 |
| 3745 TouchEvent.prototype = Object.create(UIEvent.prototype); | 3770 TouchEvent.prototype = Object.create(UIEvent.prototype); |
| 3746 | 3771 |
| 3747 mixin(TouchEvent.prototype, { | 3772 mixin(TouchEvent.prototype, { |
| 3748 get touches() { | 3773 get touches() { |
| 3749 return wrapTouchList(unwrap(this).touches); | 3774 return wrapTouchList(unsafeUnwrap(this).touches); |
| 3750 }, | 3775 }, |
| 3751 | 3776 |
| 3752 get targetTouches() { | 3777 get targetTouches() { |
| 3753 return wrapTouchList(unwrap(this).targetTouches); | 3778 return wrapTouchList(unsafeUnwrap(this).targetTouches); |
| 3754 }, | 3779 }, |
| 3755 | 3780 |
| 3756 get changedTouches() { | 3781 get changedTouches() { |
| 3757 return wrapTouchList(unwrap(this).changedTouches); | 3782 return wrapTouchList(unsafeUnwrap(this).changedTouches); |
| 3758 }, | 3783 }, |
| 3759 | 3784 |
| 3760 initTouchEvent: function() { | 3785 initTouchEvent: function() { |
| 3761 // The only way to use this is to reuse the TouchList from an existing | 3786 // The only way to use this is to reuse the TouchList from an existing |
| 3762 // TouchEvent. Since this is WebKit/Blink proprietary API we will not | 3787 // TouchEvent. Since this is WebKit/Blink proprietary API we will not |
| 3763 // implement this until someone screams. | 3788 // implement this until someone screams. |
| 3764 throw new Error('Not implemented'); | 3789 throw new Error('Not implemented'); |
| 3765 } | 3790 } |
| 3766 }); | 3791 }); |
| 3767 | 3792 |
| 3768 registerWrapper(OriginalTouchEvent, TouchEvent, nativeEvent); | 3793 registerWrapper(OriginalTouchEvent, TouchEvent, nativeEvent); |
| 3769 | 3794 |
| 3770 scope.wrappers.Touch = Touch; | 3795 scope.wrappers.Touch = Touch; |
| 3771 scope.wrappers.TouchEvent = TouchEvent; | 3796 scope.wrappers.TouchEvent = TouchEvent; |
| 3772 scope.wrappers.TouchList = TouchList; | 3797 scope.wrappers.TouchList = TouchList; |
| 3773 | 3798 |
| 3774 })(window.ShadowDOMPolyfill); | 3799 })(window.ShadowDOMPolyfill); |
| 3775 | 3800 |
| 3776 | 3801 |
| 3777 // Copyright 2012 The Polymer Authors. All rights reserved. | 3802 // Copyright 2012 The Polymer Authors. All rights reserved. |
| 3778 // Use of this source code is goverened by a BSD-style | 3803 // Use of this source code is goverened by a BSD-style |
| 3779 // license that can be found in the LICENSE file. | 3804 // license that can be found in the LICENSE file. |
| 3780 | 3805 |
| 3781 (function(scope) { | 3806 (function(scope) { |
| 3782 'use strict'; | 3807 'use strict'; |
| 3783 | 3808 |
| 3809 var unsafeUnwrap = scope.unsafeUnwrap; |
| 3784 var wrap = scope.wrap; | 3810 var wrap = scope.wrap; |
| 3785 | 3811 |
| 3786 var nonEnumDescriptor = {enumerable: false}; | 3812 var nonEnumDescriptor = {enumerable: false}; |
| 3787 | 3813 |
| 3788 function nonEnum(obj, prop) { | 3814 function nonEnum(obj, prop) { |
| 3789 Object.defineProperty(obj, prop, nonEnumDescriptor); | 3815 Object.defineProperty(obj, prop, nonEnumDescriptor); |
| 3790 } | 3816 } |
| 3791 | 3817 |
| 3792 function NodeList() { | 3818 function NodeList() { |
| 3793 this.length = 0; | 3819 this.length = 0; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3806 var wrapperList = new NodeList(); | 3832 var wrapperList = new NodeList(); |
| 3807 for (var i = 0, length = list.length; i < length; i++) { | 3833 for (var i = 0, length = list.length; i < length; i++) { |
| 3808 wrapperList[i] = wrap(list[i]); | 3834 wrapperList[i] = wrap(list[i]); |
| 3809 } | 3835 } |
| 3810 wrapperList.length = length; | 3836 wrapperList.length = length; |
| 3811 return wrapperList; | 3837 return wrapperList; |
| 3812 } | 3838 } |
| 3813 | 3839 |
| 3814 function addWrapNodeListMethod(wrapperConstructor, name) { | 3840 function addWrapNodeListMethod(wrapperConstructor, name) { |
| 3815 wrapperConstructor.prototype[name] = function() { | 3841 wrapperConstructor.prototype[name] = function() { |
| 3816 return wrapNodeList(this.impl[name].apply(this.impl, arguments)); | 3842 return wrapNodeList( |
| 3843 unsafeUnwrap(this)[name].apply(unsafeUnwrap(this), arguments)); |
| 3817 }; | 3844 }; |
| 3818 } | 3845 } |
| 3819 | 3846 |
| 3820 scope.wrappers.NodeList = NodeList; | 3847 scope.wrappers.NodeList = NodeList; |
| 3821 scope.addWrapNodeListMethod = addWrapNodeListMethod; | 3848 scope.addWrapNodeListMethod = addWrapNodeListMethod; |
| 3822 scope.wrapNodeList = wrapNodeList; | 3849 scope.wrapNodeList = wrapNodeList; |
| 3823 | 3850 |
| 3824 })(window.ShadowDOMPolyfill); | 3851 })(window.ShadowDOMPolyfill); |
| 3825 | 3852 |
| 3826 /* | 3853 /* |
| (...skipping 26 matching lines...) Expand all Loading... |
| 3853 var TreeScope = scope.TreeScope; | 3880 var TreeScope = scope.TreeScope; |
| 3854 var assert = scope.assert; | 3881 var assert = scope.assert; |
| 3855 var defineWrapGetter = scope.defineWrapGetter; | 3882 var defineWrapGetter = scope.defineWrapGetter; |
| 3856 var enqueueMutation = scope.enqueueMutation; | 3883 var enqueueMutation = scope.enqueueMutation; |
| 3857 var getTreeScope = scope.getTreeScope; | 3884 var getTreeScope = scope.getTreeScope; |
| 3858 var isWrapper = scope.isWrapper; | 3885 var isWrapper = scope.isWrapper; |
| 3859 var mixin = scope.mixin; | 3886 var mixin = scope.mixin; |
| 3860 var registerTransientObservers = scope.registerTransientObservers; | 3887 var registerTransientObservers = scope.registerTransientObservers; |
| 3861 var registerWrapper = scope.registerWrapper; | 3888 var registerWrapper = scope.registerWrapper; |
| 3862 var setTreeScope = scope.setTreeScope; | 3889 var setTreeScope = scope.setTreeScope; |
| 3890 var unsafeUnwrap = scope.unsafeUnwrap; |
| 3863 var unwrap = scope.unwrap; | 3891 var unwrap = scope.unwrap; |
| 3864 var unwrapIfNeeded = scope.unwrapIfNeeded; | 3892 var unwrapIfNeeded = scope.unwrapIfNeeded; |
| 3865 var wrap = scope.wrap; | 3893 var wrap = scope.wrap; |
| 3866 var wrapIfNeeded = scope.wrapIfNeeded; | 3894 var wrapIfNeeded = scope.wrapIfNeeded; |
| 3867 var wrappers = scope.wrappers; | 3895 var wrappers = scope.wrappers; |
| 3868 | 3896 |
| 3869 function assertIsNodeWrapper(node) { | 3897 function assertIsNodeWrapper(node) { |
| 3870 assert(node instanceof Node); | 3898 assert(node instanceof Node); |
| 3871 } | 3899 } |
| 3872 | 3900 |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4086 n.parentNode.removeChild(n); | 4114 n.parentNode.removeChild(n); |
| 4087 } | 4115 } |
| 4088 } | 4116 } |
| 4089 | 4117 |
| 4090 var originalImportNode = document.importNode; | 4118 var originalImportNode = document.importNode; |
| 4091 var originalCloneNode = window.Node.prototype.cloneNode; | 4119 var originalCloneNode = window.Node.prototype.cloneNode; |
| 4092 | 4120 |
| 4093 function cloneNode(node, deep, opt_doc) { | 4121 function cloneNode(node, deep, opt_doc) { |
| 4094 var clone; | 4122 var clone; |
| 4095 if (opt_doc) | 4123 if (opt_doc) |
| 4096 clone = wrap(originalImportNode.call(opt_doc, node.impl, false)); | 4124 clone = wrap(originalImportNode.call(opt_doc, unsafeUnwrap(node), false)); |
| 4097 else | 4125 else |
| 4098 clone = wrap(originalCloneNode.call(node.impl, false)); | 4126 clone = wrap(originalCloneNode.call(unsafeUnwrap(node), false)); |
| 4099 | 4127 |
| 4100 if (deep) { | 4128 if (deep) { |
| 4101 for (var child = node.firstChild; child; child = child.nextSibling) { | 4129 for (var child = node.firstChild; child; child = child.nextSibling) { |
| 4102 clone.appendChild(cloneNode(child, true, opt_doc)); | 4130 clone.appendChild(cloneNode(child, true, opt_doc)); |
| 4103 } | 4131 } |
| 4104 | 4132 |
| 4105 if (node instanceof wrappers.HTMLTemplateElement) { | 4133 if (node instanceof wrappers.HTMLTemplateElement) { |
| 4106 var cloneContent = clone.content; | 4134 var cloneContent = clone.content; |
| 4107 for (var child = node.content.firstChild; | 4135 for (var child = node.content.firstChild; |
| 4108 child; | 4136 child; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4231 !invalidateParent(childWrapper); | 4259 !invalidateParent(childWrapper); |
| 4232 | 4260 |
| 4233 if (useNative) | 4261 if (useNative) |
| 4234 nodes = collectNodesNative(childWrapper); | 4262 nodes = collectNodesNative(childWrapper); |
| 4235 else | 4263 else |
| 4236 nodes = collectNodes(childWrapper, this, previousNode, refWrapper); | 4264 nodes = collectNodes(childWrapper, this, previousNode, refWrapper); |
| 4237 | 4265 |
| 4238 if (useNative) { | 4266 if (useNative) { |
| 4239 ensureSameOwnerDocument(this, childWrapper); | 4267 ensureSameOwnerDocument(this, childWrapper); |
| 4240 clearChildNodes(this); | 4268 clearChildNodes(this); |
| 4241 originalInsertBefore.call(this.impl, unwrap(childWrapper), refNode); | 4269 originalInsertBefore.call(unsafeUnwrap(this), unwrap(childWrapper), refN
ode); |
| 4242 } else { | 4270 } else { |
| 4243 if (!previousNode) | 4271 if (!previousNode) |
| 4244 this.firstChild_ = nodes[0]; | 4272 this.firstChild_ = nodes[0]; |
| 4245 if (!refWrapper) { | 4273 if (!refWrapper) { |
| 4246 this.lastChild_ = nodes[nodes.length - 1]; | 4274 this.lastChild_ = nodes[nodes.length - 1]; |
| 4247 if (this.firstChild_ === undefined) | 4275 if (this.firstChild_ === undefined) |
| 4248 this.firstChild_ = this.firstChild; | 4276 this.firstChild_ = this.firstChild; |
| 4249 } | 4277 } |
| 4250 | 4278 |
| 4251 var parentNode = refNode ? refNode.parentNode : this.impl; | 4279 var parentNode = refNode ? refNode.parentNode : unsafeUnwrap(this); |
| 4252 | 4280 |
| 4253 // insertBefore refWrapper no matter what the parent is? | 4281 // insertBefore refWrapper no matter what the parent is? |
| 4254 if (parentNode) { | 4282 if (parentNode) { |
| 4255 originalInsertBefore.call(parentNode, | 4283 originalInsertBefore.call(parentNode, |
| 4256 unwrapNodesForInsertion(this, nodes), refNode); | 4284 unwrapNodesForInsertion(this, nodes), refNode); |
| 4257 } else { | 4285 } else { |
| 4258 adoptNodesIfNeeded(this, nodes); | 4286 adoptNodesIfNeeded(this, nodes); |
| 4259 } | 4287 } |
| 4260 } | 4288 } |
| 4261 | 4289 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4312 childWrapperPreviousSibling.nextSibling_ = childWrapperNextSibling; | 4340 childWrapperPreviousSibling.nextSibling_ = childWrapperNextSibling; |
| 4313 if (childWrapperNextSibling) { | 4341 if (childWrapperNextSibling) { |
| 4314 childWrapperNextSibling.previousSibling_ = | 4342 childWrapperNextSibling.previousSibling_ = |
| 4315 childWrapperPreviousSibling; | 4343 childWrapperPreviousSibling; |
| 4316 } | 4344 } |
| 4317 | 4345 |
| 4318 childWrapper.previousSibling_ = childWrapper.nextSibling_ = | 4346 childWrapper.previousSibling_ = childWrapper.nextSibling_ = |
| 4319 childWrapper.parentNode_ = undefined; | 4347 childWrapper.parentNode_ = undefined; |
| 4320 } else { | 4348 } else { |
| 4321 clearChildNodes(this); | 4349 clearChildNodes(this); |
| 4322 removeChildOriginalHelper(this.impl, childNode); | 4350 removeChildOriginalHelper(unsafeUnwrap(this), childNode); |
| 4323 } | 4351 } |
| 4324 | 4352 |
| 4325 if (!surpressMutations) { | 4353 if (!surpressMutations) { |
| 4326 enqueueMutation(this, 'childList', { | 4354 enqueueMutation(this, 'childList', { |
| 4327 removedNodes: createOneElementNodeList(childWrapper), | 4355 removedNodes: createOneElementNodeList(childWrapper), |
| 4328 nextSibling: childWrapperNextSibling, | 4356 nextSibling: childWrapperNextSibling, |
| 4329 previousSibling: childWrapperPreviousSibling | 4357 previousSibling: childWrapperPreviousSibling |
| 4330 }); | 4358 }); |
| 4331 } | 4359 } |
| 4332 | 4360 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4378 // replaceChild no matter what the parent is? | 4406 // replaceChild no matter what the parent is? |
| 4379 if (oldChildNode.parentNode) { | 4407 if (oldChildNode.parentNode) { |
| 4380 originalReplaceChild.call( | 4408 originalReplaceChild.call( |
| 4381 oldChildNode.parentNode, | 4409 oldChildNode.parentNode, |
| 4382 unwrapNodesForInsertion(this, nodes), | 4410 unwrapNodesForInsertion(this, nodes), |
| 4383 oldChildNode); | 4411 oldChildNode); |
| 4384 } | 4412 } |
| 4385 } else { | 4413 } else { |
| 4386 ensureSameOwnerDocument(this, newChildWrapper); | 4414 ensureSameOwnerDocument(this, newChildWrapper); |
| 4387 clearChildNodes(this); | 4415 clearChildNodes(this); |
| 4388 originalReplaceChild.call(this.impl, unwrap(newChildWrapper), | 4416 originalReplaceChild.call(unsafeUnwrap(this), unwrap(newChildWrapper), |
| 4389 oldChildNode); | 4417 oldChildNode); |
| 4390 } | 4418 } |
| 4391 | 4419 |
| 4392 enqueueMutation(this, 'childList', { | 4420 enqueueMutation(this, 'childList', { |
| 4393 addedNodes: nodes, | 4421 addedNodes: nodes, |
| 4394 removedNodes: createOneElementNodeList(oldChildWrapper), | 4422 removedNodes: createOneElementNodeList(oldChildWrapper), |
| 4395 nextSibling: nextNode, | 4423 nextSibling: nextNode, |
| 4396 previousSibling: previousNode | 4424 previousSibling: previousNode |
| 4397 }); | 4425 }); |
| 4398 | 4426 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 4414 }, | 4442 }, |
| 4415 | 4443 |
| 4416 hasChildNodes: function() { | 4444 hasChildNodes: function() { |
| 4417 return this.firstChild !== null; | 4445 return this.firstChild !== null; |
| 4418 }, | 4446 }, |
| 4419 | 4447 |
| 4420 /** @type {Node} */ | 4448 /** @type {Node} */ |
| 4421 get parentNode() { | 4449 get parentNode() { |
| 4422 // If the parentNode has not been overridden, use the original parentNode. | 4450 // If the parentNode has not been overridden, use the original parentNode. |
| 4423 return this.parentNode_ !== undefined ? | 4451 return this.parentNode_ !== undefined ? |
| 4424 this.parentNode_ : wrap(this.impl.parentNode); | 4452 this.parentNode_ : wrap(unsafeUnwrap(this).parentNode); |
| 4425 }, | 4453 }, |
| 4426 | 4454 |
| 4427 /** @type {Node} */ | 4455 /** @type {Node} */ |
| 4428 get firstChild() { | 4456 get firstChild() { |
| 4429 return this.firstChild_ !== undefined ? | 4457 return this.firstChild_ !== undefined ? |
| 4430 this.firstChild_ : wrap(this.impl.firstChild); | 4458 this.firstChild_ : wrap(unsafeUnwrap(this).firstChild); |
| 4431 }, | 4459 }, |
| 4432 | 4460 |
| 4433 /** @type {Node} */ | 4461 /** @type {Node} */ |
| 4434 get lastChild() { | 4462 get lastChild() { |
| 4435 return this.lastChild_ !== undefined ? | 4463 return this.lastChild_ !== undefined ? |
| 4436 this.lastChild_ : wrap(this.impl.lastChild); | 4464 this.lastChild_ : wrap(unsafeUnwrap(this).lastChild); |
| 4437 }, | 4465 }, |
| 4438 | 4466 |
| 4439 /** @type {Node} */ | 4467 /** @type {Node} */ |
| 4440 get nextSibling() { | 4468 get nextSibling() { |
| 4441 return this.nextSibling_ !== undefined ? | 4469 return this.nextSibling_ !== undefined ? |
| 4442 this.nextSibling_ : wrap(this.impl.nextSibling); | 4470 this.nextSibling_ : wrap(unsafeUnwrap(this).nextSibling); |
| 4443 }, | 4471 }, |
| 4444 | 4472 |
| 4445 /** @type {Node} */ | 4473 /** @type {Node} */ |
| 4446 get previousSibling() { | 4474 get previousSibling() { |
| 4447 return this.previousSibling_ !== undefined ? | 4475 return this.previousSibling_ !== undefined ? |
| 4448 this.previousSibling_ : wrap(this.impl.previousSibling); | 4476 this.previousSibling_ : wrap(unsafeUnwrap(this).previousSibling); |
| 4449 }, | 4477 }, |
| 4450 | 4478 |
| 4451 get parentElement() { | 4479 get parentElement() { |
| 4452 var p = this.parentNode; | 4480 var p = this.parentNode; |
| 4453 while (p && p.nodeType !== Node.ELEMENT_NODE) { | 4481 while (p && p.nodeType !== Node.ELEMENT_NODE) { |
| 4454 p = p.parentNode; | 4482 p = p.parentNode; |
| 4455 } | 4483 } |
| 4456 return p; | 4484 return p; |
| 4457 }, | 4485 }, |
| 4458 | 4486 |
| 4459 get textContent() { | 4487 get textContent() { |
| 4460 // TODO(arv): This should fallback to this.impl.textContent if there | 4488 // TODO(arv): This should fallback to unsafeUnwrap(this).textContent if th
ere |
| 4461 // are no shadow trees below or above the context node. | 4489 // are no shadow trees below or above the context node. |
| 4462 var s = ''; | 4490 var s = ''; |
| 4463 for (var child = this.firstChild; child; child = child.nextSibling) { | 4491 for (var child = this.firstChild; child; child = child.nextSibling) { |
| 4464 if (child.nodeType != Node.COMMENT_NODE) { | 4492 if (child.nodeType != Node.COMMENT_NODE) { |
| 4465 s += child.textContent; | 4493 s += child.textContent; |
| 4466 } | 4494 } |
| 4467 } | 4495 } |
| 4468 return s; | 4496 return s; |
| 4469 }, | 4497 }, |
| 4470 set textContent(textContent) { | 4498 set textContent(textContent) { |
| 4471 var removedNodes = snapshotNodeList(this.childNodes); | 4499 var removedNodes = snapshotNodeList(this.childNodes); |
| 4472 | 4500 |
| 4473 if (this.invalidateShadowRenderer()) { | 4501 if (this.invalidateShadowRenderer()) { |
| 4474 removeAllChildNodes(this); | 4502 removeAllChildNodes(this); |
| 4475 if (textContent !== '') { | 4503 if (textContent !== '') { |
| 4476 var textNode = this.impl.ownerDocument.createTextNode(textContent); | 4504 var textNode = unsafeUnwrap(this).ownerDocument.createTextNode(textCon
tent); |
| 4477 this.appendChild(textNode); | 4505 this.appendChild(textNode); |
| 4478 } | 4506 } |
| 4479 } else { | 4507 } else { |
| 4480 clearChildNodes(this); | 4508 clearChildNodes(this); |
| 4481 this.impl.textContent = textContent; | 4509 unsafeUnwrap(this).textContent = textContent; |
| 4482 } | 4510 } |
| 4483 | 4511 |
| 4484 var addedNodes = snapshotNodeList(this.childNodes); | 4512 var addedNodes = snapshotNodeList(this.childNodes); |
| 4485 | 4513 |
| 4486 enqueueMutation(this, 'childList', { | 4514 enqueueMutation(this, 'childList', { |
| 4487 addedNodes: addedNodes, | 4515 addedNodes: addedNodes, |
| 4488 removedNodes: removedNodes | 4516 removedNodes: removedNodes |
| 4489 }); | 4517 }); |
| 4490 | 4518 |
| 4491 nodesWereRemoved(removedNodes); | 4519 nodesWereRemoved(removedNodes); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 4506 return cloneNode(this, deep); | 4534 return cloneNode(this, deep); |
| 4507 }, | 4535 }, |
| 4508 | 4536 |
| 4509 contains: function(child) { | 4537 contains: function(child) { |
| 4510 return contains(this, wrapIfNeeded(child)); | 4538 return contains(this, wrapIfNeeded(child)); |
| 4511 }, | 4539 }, |
| 4512 | 4540 |
| 4513 compareDocumentPosition: function(otherNode) { | 4541 compareDocumentPosition: function(otherNode) { |
| 4514 // This only wraps, it therefore only operates on the composed DOM and not | 4542 // This only wraps, it therefore only operates on the composed DOM and not |
| 4515 // the logical DOM. | 4543 // the logical DOM. |
| 4516 return originalCompareDocumentPosition.call(this.impl, | 4544 return originalCompareDocumentPosition.call(unsafeUnwrap(this), |
| 4517 unwrapIfNeeded(otherNode)); | 4545 unwrapIfNeeded(otherNode)); |
| 4518 }, | 4546 }, |
| 4519 | 4547 |
| 4520 normalize: function() { | 4548 normalize: function() { |
| 4521 var nodes = snapshotNodeList(this.childNodes); | 4549 var nodes = snapshotNodeList(this.childNodes); |
| 4522 var remNodes = []; | 4550 var remNodes = []; |
| 4523 var s = ''; | 4551 var s = ''; |
| 4524 var modNode; | 4552 var modNode; |
| 4525 | 4553 |
| 4526 for (var i = 0, n; i < nodes.length; i++) { | 4554 for (var i = 0, n; i < nodes.length; i++) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4577 | 4605 |
| 4578 // Copyright 2013 The Polymer Authors. All rights reserved. | 4606 // Copyright 2013 The Polymer Authors. All rights reserved. |
| 4579 // Use of this source code is governed by a BSD-style | 4607 // Use of this source code is governed by a BSD-style |
| 4580 // license that can be found in the LICENSE file. | 4608 // license that can be found in the LICENSE file. |
| 4581 | 4609 |
| 4582 (function(scope) { | 4610 (function(scope) { |
| 4583 'use strict'; | 4611 'use strict'; |
| 4584 | 4612 |
| 4585 var HTMLCollection = scope.wrappers.HTMLCollection; | 4613 var HTMLCollection = scope.wrappers.HTMLCollection; |
| 4586 var NodeList = scope.wrappers.NodeList; | 4614 var NodeList = scope.wrappers.NodeList; |
| 4615 var getTreeScope = scope.getTreeScope; |
| 4616 var unsafeUnwrap = scope.unsafeUnwrap; |
| 4617 var wrap = scope.wrap; |
| 4618 |
| 4619 var originalDocumentQuerySelector = document.querySelector; |
| 4620 var originalElementQuerySelector = document.documentElement.querySelector; |
| 4621 |
| 4622 var originalDocumentQuerySelectorAll = document.querySelectorAll; |
| 4623 var originalElementQuerySelectorAll = document.documentElement.querySelectorAl
l; |
| 4624 |
| 4625 var originalDocumentGetElementsByTagName = document.getElementsByTagName; |
| 4626 var originalElementGetElementsByTagName = document.documentElement.getElements
ByTagName; |
| 4627 |
| 4628 var originalDocumentGetElementsByTagNameNS = document.getElementsByTagNameNS; |
| 4629 var originalElementGetElementsByTagNameNS = document.documentElement.getElemen
tsByTagNameNS; |
| 4630 |
| 4631 var OriginalElement = window.Element; |
| 4632 var OriginalDocument = window.HTMLDocument || window.Document; |
| 4633 |
| 4634 function filterNodeList(list, index, result, deep) { |
| 4635 var wrappedItem = null; |
| 4636 var root = null; |
| 4637 for (var i = 0, length = list.length; i < length; i++) { |
| 4638 wrappedItem = wrap(list[i]); |
| 4639 if (!deep && (root = getTreeScope(wrappedItem).root)) { |
| 4640 if (root instanceof scope.wrappers.ShadowRoot) { |
| 4641 continue; |
| 4642 } |
| 4643 } |
| 4644 result[index++] = wrappedItem; |
| 4645 } |
| 4646 |
| 4647 return index; |
| 4648 } |
| 4649 |
| 4650 function shimSelector(selector) { |
| 4651 return String(selector).replace(/\/deep\//g, ' '); |
| 4652 } |
| 4587 | 4653 |
| 4588 function findOne(node, selector) { | 4654 function findOne(node, selector) { |
| 4589 var m, el = node.firstElementChild; | 4655 var m, el = node.firstElementChild; |
| 4590 while (el) { | 4656 while (el) { |
| 4591 if (el.matches(selector)) | 4657 if (el.matches(selector)) |
| 4592 return el; | 4658 return el; |
| 4593 m = findOne(el, selector); | 4659 m = findOne(el, selector); |
| 4594 if (m) | 4660 if (m) |
| 4595 return m; | 4661 return m; |
| 4596 el = el.nextElementSibling; | 4662 el = el.nextElementSibling; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 4607 function matchesTagName(el, localName, localNameLowerCase) { | 4673 function matchesTagName(el, localName, localNameLowerCase) { |
| 4608 var ln = el.localName; | 4674 var ln = el.localName; |
| 4609 return ln === localName || | 4675 return ln === localName || |
| 4610 ln === localNameLowerCase && el.namespaceURI === XHTML_NS; | 4676 ln === localNameLowerCase && el.namespaceURI === XHTML_NS; |
| 4611 } | 4677 } |
| 4612 | 4678 |
| 4613 function matchesEveryThing() { | 4679 function matchesEveryThing() { |
| 4614 return true; | 4680 return true; |
| 4615 } | 4681 } |
| 4616 | 4682 |
| 4617 function matchesLocalName(el, localName) { | 4683 function matchesLocalNameOnly(el, ns, localName) { |
| 4618 return el.localName === localName; | 4684 return el.localName === localName; |
| 4619 } | 4685 } |
| 4620 | 4686 |
| 4621 function matchesNameSpace(el, ns) { | 4687 function matchesNameSpace(el, ns) { |
| 4622 return el.namespaceURI === ns; | 4688 return el.namespaceURI === ns; |
| 4623 } | 4689 } |
| 4624 | 4690 |
| 4625 function matchesLocalNameNS(el, ns, localName) { | 4691 function matchesLocalNameNS(el, ns, localName) { |
| 4626 return el.namespaceURI === ns && el.localName === localName; | 4692 return el.namespaceURI === ns && el.localName === localName; |
| 4627 } | 4693 } |
| 4628 | 4694 |
| 4629 function findElements(node, result, p, arg0, arg1) { | 4695 function findElements(node, index, result, p, arg0, arg1) { |
| 4630 var el = node.firstElementChild; | 4696 var el = node.firstElementChild; |
| 4631 while (el) { | 4697 while (el) { |
| 4632 if (p(el, arg0, arg1)) | 4698 if (p(el, arg0, arg1)) |
| 4633 result[result.length++] = el; | 4699 result[index++] = el; |
| 4634 findElements(el, result, p, arg0, arg1); | 4700 index = findElements(el, index, result, p, arg0, arg1); |
| 4635 el = el.nextElementSibling; | 4701 el = el.nextElementSibling; |
| 4636 } | 4702 } |
| 4637 return result; | 4703 return index; |
| 4638 } | 4704 } |
| 4639 | 4705 |
| 4640 // find and findAll will only match Simple Selectors, | 4706 // find and findAll will only match Simple Selectors, |
| 4641 // Structural Pseudo Classes are not guarenteed to be correct | 4707 // Structural Pseudo Classes are not guarenteed to be correct |
| 4642 // http://www.w3.org/TR/css3-selectors/#simple-selectors | 4708 // http://www.w3.org/TR/css3-selectors/#simple-selectors |
| 4643 | 4709 |
| 4710 function querySelectorAllFiltered(p, index, result, selector, deep) { |
| 4711 var target = unsafeUnwrap(this); |
| 4712 var list; |
| 4713 var root = getTreeScope(this).root; |
| 4714 if (root instanceof scope.wrappers.ShadowRoot) { |
| 4715 // We are in the shadow tree and the logical tree is |
| 4716 // going to be disconnected so we do a manual tree traversal |
| 4717 return findElements(this, index, result, p, selector, null); |
| 4718 } else if (target instanceof OriginalElement) { |
| 4719 list = originalElementQuerySelectorAll.call(target, selector); |
| 4720 } else if (target instanceof OriginalDocument) { |
| 4721 list = originalDocumentQuerySelectorAll.call(target, selector); |
| 4722 } else { |
| 4723 // When we get a ShadowRoot the logical tree is going to be disconnected |
| 4724 // so we do a manual tree traversal |
| 4725 return findElements(this, index, result, p, selector, null); |
| 4726 } |
| 4727 |
| 4728 return filterNodeList(list, index, result, deep); |
| 4729 } |
| 4730 |
| 4644 var SelectorsInterface = { | 4731 var SelectorsInterface = { |
| 4645 querySelector: function(selector) { | 4732 querySelector: function(selector) { |
| 4646 return findOne(this, selector); | 4733 var shimmed = shimSelector(selector); |
| 4734 var deep = shimmed !== selector; |
| 4735 selector = shimmed; |
| 4736 |
| 4737 var target = unsafeUnwrap(this); |
| 4738 var wrappedItem; |
| 4739 var root = getTreeScope(this).root; |
| 4740 if (root instanceof scope.wrappers.ShadowRoot) { |
| 4741 // We are in the shadow tree and the logical tree is |
| 4742 // going to be disconnected so we do a manual tree traversal |
| 4743 return findOne(this, selector); |
| 4744 } else if (target instanceof OriginalElement) { |
| 4745 wrappedItem = wrap(originalElementQuerySelector.call(target, selector)); |
| 4746 } else if (target instanceof OriginalDocument) { |
| 4747 wrappedItem = wrap(originalDocumentQuerySelector.call(target, selector))
; |
| 4748 } else { |
| 4749 // When we get a ShadowRoot the logical tree is going to be disconnected |
| 4750 // so we do a manual tree traversal |
| 4751 return findOne(this, selector); |
| 4752 } |
| 4753 |
| 4754 if (!wrappedItem) { |
| 4755 // When the original query returns nothing |
| 4756 // we return nothing (to be consistent with the other wrapped calls) |
| 4757 return wrappedItem; |
| 4758 } else if (!deep && (root = getTreeScope(wrappedItem).root)) { |
| 4759 if (root instanceof scope.wrappers.ShadowRoot) { |
| 4760 // When the original query returns an element in the ShadowDOM |
| 4761 // we must do a manual tree traversal |
| 4762 return findOne(this, selector); |
| 4763 } |
| 4764 } |
| 4765 |
| 4766 return wrappedItem; |
| 4647 }, | 4767 }, |
| 4648 querySelectorAll: function(selector) { | 4768 querySelectorAll: function(selector) { |
| 4649 return findElements(this, new NodeList(), matchesSelector, selector); | 4769 var shimmed = shimSelector(selector); |
| 4770 var deep = shimmed !== selector; |
| 4771 selector = shimmed; |
| 4772 |
| 4773 var result = new NodeList(); |
| 4774 |
| 4775 result.length = querySelectorAllFiltered.call(this, |
| 4776 matchesSelector, |
| 4777 0, |
| 4778 result, |
| 4779 selector, |
| 4780 deep); |
| 4781 |
| 4782 return result; |
| 4650 } | 4783 } |
| 4651 }; | 4784 }; |
| 4652 | 4785 |
| 4786 function getElementsByTagNameFiltered(p, index, result, localName, |
| 4787 lowercase) { |
| 4788 var target = unsafeUnwrap(this); |
| 4789 var list; |
| 4790 var root = getTreeScope(this).root; |
| 4791 if (root instanceof scope.wrappers.ShadowRoot) { |
| 4792 // We are in the shadow tree and the logical tree is |
| 4793 // going to be disconnected so we do a manual tree traversal |
| 4794 return findElements(this, index, result, p, localName, lowercase); |
| 4795 } else if (target instanceof OriginalElement) { |
| 4796 list = originalElementGetElementsByTagName.call(target, localName, |
| 4797 lowercase); |
| 4798 } else if (target instanceof OriginalDocument) { |
| 4799 list = originalDocumentGetElementsByTagName.call(target, localName, |
| 4800 lowercase); |
| 4801 } else { |
| 4802 // When we get a ShadowRoot the logical tree is going to be disconnected |
| 4803 // so we do a manual tree traversal |
| 4804 return findElements(this, index, result, p, localName, lowercase); |
| 4805 } |
| 4806 |
| 4807 return filterNodeList(list, index, result, false); |
| 4808 } |
| 4809 |
| 4810 function getElementsByTagNameNSFiltered(p, index, result, ns, localName) { |
| 4811 var target = unsafeUnwrap(this); |
| 4812 var list; |
| 4813 var root = getTreeScope(this).root; |
| 4814 if (root instanceof scope.wrappers.ShadowRoot) { |
| 4815 // We are in the shadow tree and the logical tree is |
| 4816 // going to be disconnected so we do a manual tree traversal |
| 4817 return findElements(this, index, result, p, ns, localName); |
| 4818 } else if (target instanceof OriginalElement) { |
| 4819 list = originalElementGetElementsByTagNameNS.call(target, ns, localName); |
| 4820 } else if (target instanceof OriginalDocument) { |
| 4821 list = originalDocumentGetElementsByTagNameNS.call(target, ns, localName); |
| 4822 } else { |
| 4823 // When we get a ShadowRoot the logical tree is going to be disconnected |
| 4824 // so we do a manual tree traversal |
| 4825 return findElements(this, index, result, p, ns, localName); |
| 4826 } |
| 4827 |
| 4828 return filterNodeList(list, index, result, false); |
| 4829 } |
| 4830 |
| 4653 var GetElementsByInterface = { | 4831 var GetElementsByInterface = { |
| 4654 getElementsByTagName: function(localName) { | 4832 getElementsByTagName: function(localName) { |
| 4655 var result = new HTMLCollection(); | 4833 var result = new HTMLCollection(); |
| 4656 if (localName === '*') | 4834 var match = localName === '*' ? matchesEveryThing : matchesTagName; |
| 4657 return findElements(this, result, matchesEveryThing); | |
| 4658 | 4835 |
| 4659 return findElements(this, result, | 4836 result.length = getElementsByTagNameFiltered.call(this, |
| 4660 matchesTagName, | 4837 match, |
| 4838 0, |
| 4839 result, |
| 4661 localName, | 4840 localName, |
| 4662 localName.toLowerCase()); | 4841 localName.toLowerCase()); |
| 4842 |
| 4843 return result; |
| 4663 }, | 4844 }, |
| 4664 | 4845 |
| 4665 getElementsByClassName: function(className) { | 4846 getElementsByClassName: function(className) { |
| 4666 // TODO(arv): Check className? | 4847 // TODO(arv): Check className? |
| 4667 return this.querySelectorAll('.' + className); | 4848 return this.querySelectorAll('.' + className); |
| 4668 }, | 4849 }, |
| 4669 | 4850 |
| 4670 getElementsByTagNameNS: function(ns, localName) { | 4851 getElementsByTagNameNS: function(ns, localName) { |
| 4671 var result = new HTMLCollection(); | 4852 var result = new HTMLCollection(); |
| 4853 var match = null; |
| 4672 | 4854 |
| 4673 if (ns === '') { | 4855 if (ns === '*') { |
| 4674 ns = null; | 4856 match = localName === '*' ? matchesEveryThing : matchesLocalNameOnly; |
| 4675 } else if (ns === '*') { | 4857 } else { |
| 4676 if (localName === '*') | 4858 match = localName === '*' ? matchesNameSpace : matchesLocalNameNS; |
| 4677 return findElements(this, result, matchesEveryThing); | |
| 4678 return findElements(this, result, matchesLocalName, localName); | |
| 4679 } | 4859 } |
| 4680 | 4860 |
| 4681 if (localName === '*') | 4861 result.length = getElementsByTagNameNSFiltered.call(this, |
| 4682 return findElements(this, result, matchesNameSpace, ns); | 4862 match, |
| 4863 0, |
| 4864 result, |
| 4865 ns || null, |
| 4866 localName); |
| 4683 | 4867 |
| 4684 return findElements(this, result, matchesLocalNameNS, ns, localName); | 4868 return result; |
| 4685 } | 4869 } |
| 4686 }; | 4870 }; |
| 4687 | 4871 |
| 4688 scope.GetElementsByInterface = GetElementsByInterface; | 4872 scope.GetElementsByInterface = GetElementsByInterface; |
| 4689 scope.SelectorsInterface = SelectorsInterface; | 4873 scope.SelectorsInterface = SelectorsInterface; |
| 4690 | 4874 |
| 4691 })(window.ShadowDOMPolyfill); | 4875 })(window.ShadowDOMPolyfill); |
| 4692 | 4876 |
| 4693 // Copyright 2013 The Polymer Authors. All rights reserved. | 4877 // Copyright 2013 The Polymer Authors. All rights reserved. |
| 4694 // Use of this source code is goverened by a BSD-style | 4878 // Use of this source code is goverened by a BSD-style |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4771 // license that can be found in the LICENSE file. | 4955 // license that can be found in the LICENSE file. |
| 4772 | 4956 |
| 4773 (function(scope) { | 4957 (function(scope) { |
| 4774 'use strict'; | 4958 'use strict'; |
| 4775 | 4959 |
| 4776 var ChildNodeInterface = scope.ChildNodeInterface; | 4960 var ChildNodeInterface = scope.ChildNodeInterface; |
| 4777 var Node = scope.wrappers.Node; | 4961 var Node = scope.wrappers.Node; |
| 4778 var enqueueMutation = scope.enqueueMutation; | 4962 var enqueueMutation = scope.enqueueMutation; |
| 4779 var mixin = scope.mixin; | 4963 var mixin = scope.mixin; |
| 4780 var registerWrapper = scope.registerWrapper; | 4964 var registerWrapper = scope.registerWrapper; |
| 4965 var unsafeUnwrap = scope.unsafeUnwrap; |
| 4781 | 4966 |
| 4782 var OriginalCharacterData = window.CharacterData; | 4967 var OriginalCharacterData = window.CharacterData; |
| 4783 | 4968 |
| 4784 function CharacterData(node) { | 4969 function CharacterData(node) { |
| 4785 Node.call(this, node); | 4970 Node.call(this, node); |
| 4786 } | 4971 } |
| 4787 CharacterData.prototype = Object.create(Node.prototype); | 4972 CharacterData.prototype = Object.create(Node.prototype); |
| 4788 mixin(CharacterData.prototype, { | 4973 mixin(CharacterData.prototype, { |
| 4789 get textContent() { | 4974 get textContent() { |
| 4790 return this.data; | 4975 return this.data; |
| 4791 }, | 4976 }, |
| 4792 set textContent(value) { | 4977 set textContent(value) { |
| 4793 this.data = value; | 4978 this.data = value; |
| 4794 }, | 4979 }, |
| 4795 get data() { | 4980 get data() { |
| 4796 return this.impl.data; | 4981 return unsafeUnwrap(this).data; |
| 4797 }, | 4982 }, |
| 4798 set data(value) { | 4983 set data(value) { |
| 4799 var oldValue = this.impl.data; | 4984 var oldValue = unsafeUnwrap(this).data; |
| 4800 enqueueMutation(this, 'characterData', { | 4985 enqueueMutation(this, 'characterData', { |
| 4801 oldValue: oldValue | 4986 oldValue: oldValue |
| 4802 }); | 4987 }); |
| 4803 this.impl.data = value; | 4988 unsafeUnwrap(this).data = value; |
| 4804 } | 4989 } |
| 4805 }); | 4990 }); |
| 4806 | 4991 |
| 4807 mixin(CharacterData.prototype, ChildNodeInterface); | 4992 mixin(CharacterData.prototype, ChildNodeInterface); |
| 4808 | 4993 |
| 4809 registerWrapper(OriginalCharacterData, CharacterData, | 4994 registerWrapper(OriginalCharacterData, CharacterData, |
| 4810 document.createTextNode('')); | 4995 document.createTextNode('')); |
| 4811 | 4996 |
| 4812 scope.wrappers.CharacterData = CharacterData; | 4997 scope.wrappers.CharacterData = CharacterData; |
| 4813 })(window.ShadowDOMPolyfill); | 4998 })(window.ShadowDOMPolyfill); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4855 scope.wrappers.Text = Text; | 5040 scope.wrappers.Text = Text; |
| 4856 })(window.ShadowDOMPolyfill); | 5041 })(window.ShadowDOMPolyfill); |
| 4857 | 5042 |
| 4858 // Copyright 2014 The Polymer Authors. All rights reserved. | 5043 // Copyright 2014 The Polymer Authors. All rights reserved. |
| 4859 // Use of this source code is goverened by a BSD-style | 5044 // Use of this source code is goverened by a BSD-style |
| 4860 // license that can be found in the LICENSE file. | 5045 // license that can be found in the LICENSE file. |
| 4861 | 5046 |
| 4862 (function(scope) { | 5047 (function(scope) { |
| 4863 'use strict'; | 5048 'use strict'; |
| 4864 | 5049 |
| 5050 var setWrapper = scope.setWrapper; |
| 5051 var unsafeUnwrap = scope.unsafeUnwrap; |
| 5052 |
| 4865 function invalidateClass(el) { | 5053 function invalidateClass(el) { |
| 4866 scope.invalidateRendererBasedOnAttribute(el, 'class'); | 5054 scope.invalidateRendererBasedOnAttribute(el, 'class'); |
| 4867 } | 5055 } |
| 4868 | 5056 |
| 4869 function DOMTokenList(impl, ownerElement) { | 5057 function DOMTokenList(impl, ownerElement) { |
| 4870 this.impl = impl; | 5058 setWrapper(impl, this); |
| 4871 this.ownerElement_ = ownerElement; | 5059 this.ownerElement_ = ownerElement; |
| 4872 } | 5060 } |
| 4873 | 5061 |
| 4874 DOMTokenList.prototype = { | 5062 DOMTokenList.prototype = { |
| 5063 constructor: DOMTokenList, |
| 4875 get length() { | 5064 get length() { |
| 4876 return this.impl.length; | 5065 return unsafeUnwrap(this).length; |
| 4877 }, | 5066 }, |
| 4878 item: function(index) { | 5067 item: function(index) { |
| 4879 return this.impl.item(index); | 5068 return unsafeUnwrap(this).item(index); |
| 4880 }, | 5069 }, |
| 4881 contains: function(token) { | 5070 contains: function(token) { |
| 4882 return this.impl.contains(token); | 5071 return unsafeUnwrap(this).contains(token); |
| 4883 }, | 5072 }, |
| 4884 add: function() { | 5073 add: function() { |
| 4885 this.impl.add.apply(this.impl, arguments); | 5074 unsafeUnwrap(this).add.apply(unsafeUnwrap(this), arguments); |
| 4886 invalidateClass(this.ownerElement_); | 5075 invalidateClass(this.ownerElement_); |
| 4887 }, | 5076 }, |
| 4888 remove: function() { | 5077 remove: function() { |
| 4889 this.impl.remove.apply(this.impl, arguments); | 5078 unsafeUnwrap(this).remove.apply(unsafeUnwrap(this), arguments); |
| 4890 invalidateClass(this.ownerElement_); | 5079 invalidateClass(this.ownerElement_); |
| 4891 }, | 5080 }, |
| 4892 toggle: function(token) { | 5081 toggle: function(token) { |
| 4893 var rv = this.impl.toggle.apply(this.impl, arguments); | 5082 var rv = unsafeUnwrap(this).toggle.apply(unsafeUnwrap(this), arguments); |
| 4894 invalidateClass(this.ownerElement_); | 5083 invalidateClass(this.ownerElement_); |
| 4895 return rv; | 5084 return rv; |
| 4896 }, | 5085 }, |
| 4897 toString: function() { | 5086 toString: function() { |
| 4898 return this.impl.toString(); | 5087 return unsafeUnwrap(this).toString(); |
| 4899 } | 5088 } |
| 4900 }; | 5089 }; |
| 4901 | 5090 |
| 4902 scope.wrappers.DOMTokenList = DOMTokenList; | 5091 scope.wrappers.DOMTokenList = DOMTokenList; |
| 4903 })(window.ShadowDOMPolyfill); | 5092 })(window.ShadowDOMPolyfill); |
| 4904 | 5093 |
| 4905 // Copyright 2013 The Polymer Authors. All rights reserved. | 5094 // Copyright 2013 The Polymer Authors. All rights reserved. |
| 4906 // Use of this source code is goverened by a BSD-style | 5095 // Use of this source code is goverened by a BSD-style |
| 4907 // license that can be found in the LICENSE file. | 5096 // license that can be found in the LICENSE file. |
| 4908 | 5097 |
| 4909 (function(scope) { | 5098 (function(scope) { |
| 4910 'use strict'; | 5099 'use strict'; |
| 4911 | 5100 |
| 4912 var ChildNodeInterface = scope.ChildNodeInterface; | 5101 var ChildNodeInterface = scope.ChildNodeInterface; |
| 4913 var GetElementsByInterface = scope.GetElementsByInterface; | 5102 var GetElementsByInterface = scope.GetElementsByInterface; |
| 4914 var Node = scope.wrappers.Node; | 5103 var Node = scope.wrappers.Node; |
| 4915 var DOMTokenList = scope.wrappers.DOMTokenList; | 5104 var DOMTokenList = scope.wrappers.DOMTokenList; |
| 4916 var ParentNodeInterface = scope.ParentNodeInterface; | 5105 var ParentNodeInterface = scope.ParentNodeInterface; |
| 4917 var SelectorsInterface = scope.SelectorsInterface; | 5106 var SelectorsInterface = scope.SelectorsInterface; |
| 4918 var addWrapNodeListMethod = scope.addWrapNodeListMethod; | 5107 var addWrapNodeListMethod = scope.addWrapNodeListMethod; |
| 4919 var enqueueMutation = scope.enqueueMutation; | 5108 var enqueueMutation = scope.enqueueMutation; |
| 4920 var mixin = scope.mixin; | 5109 var mixin = scope.mixin; |
| 4921 var oneOf = scope.oneOf; | 5110 var oneOf = scope.oneOf; |
| 4922 var registerWrapper = scope.registerWrapper; | 5111 var registerWrapper = scope.registerWrapper; |
| 4923 var unwrap = scope.unwrap; | 5112 var unsafeUnwrap = scope.unsafeUnwrap; |
| 4924 var wrappers = scope.wrappers; | 5113 var wrappers = scope.wrappers; |
| 4925 | 5114 |
| 4926 var OriginalElement = window.Element; | 5115 var OriginalElement = window.Element; |
| 4927 | 5116 |
| 4928 var matchesNames = [ | 5117 var matchesNames = [ |
| 4929 'matches', // needs to come first. | 5118 'matches', // needs to come first. |
| 4930 'mozMatchesSelector', | 5119 'mozMatchesSelector', |
| 4931 'msMatchesSelector', | 5120 'msMatchesSelector', |
| 4932 'webkitMatchesSelector', | 5121 'webkitMatchesSelector', |
| 4933 ].filter(function(name) { | 5122 ].filter(function(name) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 4962 | 5151 |
| 4963 var classListTable = new WeakMap(); | 5152 var classListTable = new WeakMap(); |
| 4964 | 5153 |
| 4965 function Element(node) { | 5154 function Element(node) { |
| 4966 Node.call(this, node); | 5155 Node.call(this, node); |
| 4967 } | 5156 } |
| 4968 Element.prototype = Object.create(Node.prototype); | 5157 Element.prototype = Object.create(Node.prototype); |
| 4969 mixin(Element.prototype, { | 5158 mixin(Element.prototype, { |
| 4970 createShadowRoot: function() { | 5159 createShadowRoot: function() { |
| 4971 var newShadowRoot = new wrappers.ShadowRoot(this); | 5160 var newShadowRoot = new wrappers.ShadowRoot(this); |
| 4972 this.impl.polymerShadowRoot_ = newShadowRoot; | 5161 unsafeUnwrap(this).polymerShadowRoot_ = newShadowRoot; |
| 4973 | 5162 |
| 4974 var renderer = scope.getRendererForHost(this); | 5163 var renderer = scope.getRendererForHost(this); |
| 4975 renderer.invalidate(); | 5164 renderer.invalidate(); |
| 4976 | 5165 |
| 4977 return newShadowRoot; | 5166 return newShadowRoot; |
| 4978 }, | 5167 }, |
| 4979 | 5168 |
| 4980 get shadowRoot() { | 5169 get shadowRoot() { |
| 4981 return this.impl.polymerShadowRoot_ || null; | 5170 return unsafeUnwrap(this).polymerShadowRoot_ || null; |
| 4982 }, | 5171 }, |
| 4983 | 5172 |
| 4984 // getDestinationInsertionPoints added in ShadowRenderer.js | 5173 // getDestinationInsertionPoints added in ShadowRenderer.js |
| 4985 | 5174 |
| 4986 setAttribute: function(name, value) { | 5175 setAttribute: function(name, value) { |
| 4987 var oldValue = this.impl.getAttribute(name); | 5176 var oldValue = unsafeUnwrap(this).getAttribute(name); |
| 4988 this.impl.setAttribute(name, value); | 5177 unsafeUnwrap(this).setAttribute(name, value); |
| 4989 enqueAttributeChange(this, name, oldValue); | 5178 enqueAttributeChange(this, name, oldValue); |
| 4990 invalidateRendererBasedOnAttribute(this, name); | 5179 invalidateRendererBasedOnAttribute(this, name); |
| 4991 }, | 5180 }, |
| 4992 | 5181 |
| 4993 removeAttribute: function(name) { | 5182 removeAttribute: function(name) { |
| 4994 var oldValue = this.impl.getAttribute(name); | 5183 var oldValue = unsafeUnwrap(this).getAttribute(name); |
| 4995 this.impl.removeAttribute(name); | 5184 unsafeUnwrap(this).removeAttribute(name); |
| 4996 enqueAttributeChange(this, name, oldValue); | 5185 enqueAttributeChange(this, name, oldValue); |
| 4997 invalidateRendererBasedOnAttribute(this, name); | 5186 invalidateRendererBasedOnAttribute(this, name); |
| 4998 }, | 5187 }, |
| 4999 | 5188 |
| 5000 matches: function(selector) { | 5189 matches: function(selector) { |
| 5001 return originalMatches.call(this.impl, selector); | 5190 return originalMatches.call(unsafeUnwrap(this), selector); |
| 5002 }, | 5191 }, |
| 5003 | 5192 |
| 5004 get classList() { | 5193 get classList() { |
| 5005 var list = classListTable.get(this); | 5194 var list = classListTable.get(this); |
| 5006 if (!list) { | 5195 if (!list) { |
| 5007 classListTable.set(this, | 5196 classListTable.set(this, |
| 5008 list = new DOMTokenList(unwrap(this).classList, this)); | 5197 list = new DOMTokenList(unsafeUnwrap(this).classList, this)); |
| 5009 } | 5198 } |
| 5010 return list; | 5199 return list; |
| 5011 }, | 5200 }, |
| 5012 | 5201 |
| 5013 get className() { | 5202 get className() { |
| 5014 return unwrap(this).className; | 5203 return unsafeUnwrap(this).className; |
| 5015 }, | 5204 }, |
| 5016 | 5205 |
| 5017 set className(v) { | 5206 set className(v) { |
| 5018 this.setAttribute('class', v); | 5207 this.setAttribute('class', v); |
| 5019 }, | 5208 }, |
| 5020 | 5209 |
| 5021 get id() { | 5210 get id() { |
| 5022 return unwrap(this).id; | 5211 return unsafeUnwrap(this).id; |
| 5023 }, | 5212 }, |
| 5024 | 5213 |
| 5025 set id(v) { | 5214 set id(v) { |
| 5026 this.setAttribute('id', v); | 5215 this.setAttribute('id', v); |
| 5027 } | 5216 } |
| 5028 }); | 5217 }); |
| 5029 | 5218 |
| 5030 matchesNames.forEach(function(name) { | 5219 matchesNames.forEach(function(name) { |
| 5031 if (name !== 'matches') { | 5220 if (name !== 'matches') { |
| 5032 Element.prototype[name] = function(selector) { | 5221 Element.prototype[name] = function(selector) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 5061 'use strict'; | 5250 'use strict'; |
| 5062 | 5251 |
| 5063 var Element = scope.wrappers.Element; | 5252 var Element = scope.wrappers.Element; |
| 5064 var defineGetter = scope.defineGetter; | 5253 var defineGetter = scope.defineGetter; |
| 5065 var enqueueMutation = scope.enqueueMutation; | 5254 var enqueueMutation = scope.enqueueMutation; |
| 5066 var mixin = scope.mixin; | 5255 var mixin = scope.mixin; |
| 5067 var nodesWereAdded = scope.nodesWereAdded; | 5256 var nodesWereAdded = scope.nodesWereAdded; |
| 5068 var nodesWereRemoved = scope.nodesWereRemoved; | 5257 var nodesWereRemoved = scope.nodesWereRemoved; |
| 5069 var registerWrapper = scope.registerWrapper; | 5258 var registerWrapper = scope.registerWrapper; |
| 5070 var snapshotNodeList = scope.snapshotNodeList; | 5259 var snapshotNodeList = scope.snapshotNodeList; |
| 5260 var unsafeUnwrap = scope.unsafeUnwrap; |
| 5071 var unwrap = scope.unwrap; | 5261 var unwrap = scope.unwrap; |
| 5072 var wrap = scope.wrap; | 5262 var wrap = scope.wrap; |
| 5073 var wrappers = scope.wrappers; | 5263 var wrappers = scope.wrappers; |
| 5074 | 5264 |
| 5075 ///////////////////////////////////////////////////////////////////////////// | 5265 ///////////////////////////////////////////////////////////////////////////// |
| 5076 // innerHTML and outerHTML | 5266 // innerHTML and outerHTML |
| 5077 | 5267 |
| 5078 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#es
capingString | 5268 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#es
capingString |
| 5079 var escapeAttrRegExp = /[&\u00A0"]/g; | 5269 var escapeAttrRegExp = /[&\u00A0"]/g; |
| 5080 var escapeDataRegExp = /[&\u00A0<>]/g; | 5270 var escapeDataRegExp = /[&\u00A0<>]/g; |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5227 else | 5417 else |
| 5228 setInnerHTML(this, value, this.tagName); | 5418 setInnerHTML(this, value, this.tagName); |
| 5229 | 5419 |
| 5230 // If we have a non native template element we need to handle this | 5420 // If we have a non native template element we need to handle this |
| 5231 // manually since setting impl.innerHTML would add the html as direct | 5421 // manually since setting impl.innerHTML would add the html as direct |
| 5232 // children and not be moved over to the content fragment. | 5422 // children and not be moved over to the content fragment. |
| 5233 } else if (!OriginalHTMLTemplateElement && | 5423 } else if (!OriginalHTMLTemplateElement && |
| 5234 this instanceof wrappers.HTMLTemplateElement) { | 5424 this instanceof wrappers.HTMLTemplateElement) { |
| 5235 setInnerHTML(this.content, value); | 5425 setInnerHTML(this.content, value); |
| 5236 } else { | 5426 } else { |
| 5237 this.impl.innerHTML = value; | 5427 unsafeUnwrap(this).innerHTML = value; |
| 5238 } | 5428 } |
| 5239 | 5429 |
| 5240 var addedNodes = snapshotNodeList(this.childNodes); | 5430 var addedNodes = snapshotNodeList(this.childNodes); |
| 5241 | 5431 |
| 5242 enqueueMutation(this, 'childList', { | 5432 enqueueMutation(this, 'childList', { |
| 5243 addedNodes: addedNodes, | 5433 addedNodes: addedNodes, |
| 5244 removedNodes: removedNodes | 5434 removedNodes: removedNodes |
| 5245 }); | 5435 }); |
| 5246 | 5436 |
| 5247 nodesWereRemoved(removedNodes); | 5437 nodesWereRemoved(removedNodes); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 5278 case 'beforeend': | 5468 case 'beforeend': |
| 5279 contextElement = this; | 5469 contextElement = this; |
| 5280 refNode = null; | 5470 refNode = null; |
| 5281 break; | 5471 break; |
| 5282 default: | 5472 default: |
| 5283 return; | 5473 return; |
| 5284 } | 5474 } |
| 5285 | 5475 |
| 5286 var df = frag(contextElement, text); | 5476 var df = frag(contextElement, text); |
| 5287 contextElement.insertBefore(df, refNode); | 5477 contextElement.insertBefore(df, refNode); |
| 5478 }, |
| 5479 |
| 5480 get hidden() { |
| 5481 return this.hasAttribute('hidden'); |
| 5482 }, |
| 5483 set hidden(v) { |
| 5484 if (v) { |
| 5485 this.setAttribute('hidden', ''); |
| 5486 } else { |
| 5487 this.removeAttribute('hidden'); |
| 5488 } |
| 5288 } | 5489 } |
| 5289 }); | 5490 }); |
| 5290 | 5491 |
| 5291 function frag(contextElement, html) { | 5492 function frag(contextElement, html) { |
| 5292 // TODO(arv): This does not work with SVG and other non HTML elements. | 5493 // TODO(arv): This does not work with SVG and other non HTML elements. |
| 5293 var p = unwrap(contextElement.cloneNode(false)); | 5494 var p = unwrap(contextElement.cloneNode(false)); |
| 5294 p.innerHTML = html; | 5495 p.innerHTML = html; |
| 5295 var df = unwrap(document.createDocumentFragment()); | 5496 var df = unwrap(document.createDocumentFragment()); |
| 5296 var c; | 5497 var c; |
| 5297 while (c = p.firstChild) { | 5498 while (c = p.firstChild) { |
| 5298 df.appendChild(c); | 5499 df.appendChild(c); |
| 5299 } | 5500 } |
| 5300 return wrap(df); | 5501 return wrap(df); |
| 5301 } | 5502 } |
| 5302 | 5503 |
| 5303 function getter(name) { | 5504 function getter(name) { |
| 5304 return function() { | 5505 return function() { |
| 5305 scope.renderAllPending(); | 5506 scope.renderAllPending(); |
| 5306 return this.impl[name]; | 5507 return unsafeUnwrap(this)[name]; |
| 5307 }; | 5508 }; |
| 5308 } | 5509 } |
| 5309 | 5510 |
| 5310 function getterRequiresRendering(name) { | 5511 function getterRequiresRendering(name) { |
| 5311 defineGetter(HTMLElement, name, getter(name)); | 5512 defineGetter(HTMLElement, name, getter(name)); |
| 5312 } | 5513 } |
| 5313 | 5514 |
| 5314 [ | 5515 [ |
| 5315 'clientHeight', | 5516 'clientHeight', |
| 5316 'clientLeft', | 5517 'clientLeft', |
| 5317 'clientTop', | 5518 'clientTop', |
| 5318 'clientWidth', | 5519 'clientWidth', |
| 5319 'offsetHeight', | 5520 'offsetHeight', |
| 5320 'offsetLeft', | 5521 'offsetLeft', |
| 5321 'offsetTop', | 5522 'offsetTop', |
| 5322 'offsetWidth', | 5523 'offsetWidth', |
| 5323 'scrollHeight', | 5524 'scrollHeight', |
| 5324 'scrollWidth', | 5525 'scrollWidth', |
| 5325 ].forEach(getterRequiresRendering); | 5526 ].forEach(getterRequiresRendering); |
| 5326 | 5527 |
| 5327 function getterAndSetterRequiresRendering(name) { | 5528 function getterAndSetterRequiresRendering(name) { |
| 5328 Object.defineProperty(HTMLElement.prototype, name, { | 5529 Object.defineProperty(HTMLElement.prototype, name, { |
| 5329 get: getter(name), | 5530 get: getter(name), |
| 5330 set: function(v) { | 5531 set: function(v) { |
| 5331 scope.renderAllPending(); | 5532 scope.renderAllPending(); |
| 5332 this.impl[name] = v; | 5533 unsafeUnwrap(this)[name] = v; |
| 5333 }, | 5534 }, |
| 5334 configurable: true, | 5535 configurable: true, |
| 5335 enumerable: true | 5536 enumerable: true |
| 5336 }); | 5537 }); |
| 5337 } | 5538 } |
| 5338 | 5539 |
| 5339 [ | 5540 [ |
| 5340 'scrollLeft', | 5541 'scrollLeft', |
| 5341 'scrollTop', | 5542 'scrollTop', |
| 5342 ].forEach(getterAndSetterRequiresRendering); | 5543 ].forEach(getterAndSetterRequiresRendering); |
| 5343 | 5544 |
| 5344 function methodRequiresRendering(name) { | 5545 function methodRequiresRendering(name) { |
| 5345 Object.defineProperty(HTMLElement.prototype, name, { | 5546 Object.defineProperty(HTMLElement.prototype, name, { |
| 5346 value: function() { | 5547 value: function() { |
| 5347 scope.renderAllPending(); | 5548 scope.renderAllPending(); |
| 5348 return this.impl[name].apply(this.impl, arguments); | 5549 return unsafeUnwrap(this)[name].apply(unsafeUnwrap(this), arguments); |
| 5349 }, | 5550 }, |
| 5350 configurable: true, | 5551 configurable: true, |
| 5351 enumerable: true | 5552 enumerable: true |
| 5352 }); | 5553 }); |
| 5353 } | 5554 } |
| 5354 | 5555 |
| 5355 [ | 5556 [ |
| 5356 'getBoundingClientRect', | 5557 'getBoundingClientRect', |
| 5357 'getClientRects', | 5558 'getClientRects', |
| 5358 'scrollIntoView' | 5559 'scrollIntoView' |
| (...skipping 13 matching lines...) Expand all Loading... |
| 5372 // Copyright 2013 The Polymer Authors. All rights reserved. | 5573 // Copyright 2013 The Polymer Authors. All rights reserved. |
| 5373 // Use of this source code is goverened by a BSD-style | 5574 // Use of this source code is goverened by a BSD-style |
| 5374 // license that can be found in the LICENSE file. | 5575 // license that can be found in the LICENSE file. |
| 5375 | 5576 |
| 5376 (function(scope) { | 5577 (function(scope) { |
| 5377 'use strict'; | 5578 'use strict'; |
| 5378 | 5579 |
| 5379 var HTMLElement = scope.wrappers.HTMLElement; | 5580 var HTMLElement = scope.wrappers.HTMLElement; |
| 5380 var mixin = scope.mixin; | 5581 var mixin = scope.mixin; |
| 5381 var registerWrapper = scope.registerWrapper; | 5582 var registerWrapper = scope.registerWrapper; |
| 5583 var unsafeUnwrap = scope.unsafeUnwrap; |
| 5382 var wrap = scope.wrap; | 5584 var wrap = scope.wrap; |
| 5383 | 5585 |
| 5384 var OriginalHTMLCanvasElement = window.HTMLCanvasElement; | 5586 var OriginalHTMLCanvasElement = window.HTMLCanvasElement; |
| 5385 | 5587 |
| 5386 function HTMLCanvasElement(node) { | 5588 function HTMLCanvasElement(node) { |
| 5387 HTMLElement.call(this, node); | 5589 HTMLElement.call(this, node); |
| 5388 } | 5590 } |
| 5389 HTMLCanvasElement.prototype = Object.create(HTMLElement.prototype); | 5591 HTMLCanvasElement.prototype = Object.create(HTMLElement.prototype); |
| 5390 | 5592 |
| 5391 mixin(HTMLCanvasElement.prototype, { | 5593 mixin(HTMLCanvasElement.prototype, { |
| 5392 getContext: function() { | 5594 getContext: function() { |
| 5393 var context = this.impl.getContext.apply(this.impl, arguments); | 5595 var context = unsafeUnwrap(this).getContext.apply(unsafeUnwrap(this), argu
ments); |
| 5394 return context && wrap(context); | 5596 return context && wrap(context); |
| 5395 } | 5597 } |
| 5396 }); | 5598 }); |
| 5397 | 5599 |
| 5398 registerWrapper(OriginalHTMLCanvasElement, HTMLCanvasElement, | 5600 registerWrapper(OriginalHTMLCanvasElement, HTMLCanvasElement, |
| 5399 document.createElement('canvas')); | 5601 document.createElement('canvas')); |
| 5400 | 5602 |
| 5401 scope.wrappers.HTMLCanvasElement = HTMLCanvasElement; | 5603 scope.wrappers.HTMLCanvasElement = HTMLCanvasElement; |
| 5402 })(window.ShadowDOMPolyfill); | 5604 })(window.ShadowDOMPolyfill); |
| 5403 | 5605 |
| 5404 // Copyright 2013 The Polymer Authors. All rights reserved. | 5606 // Copyright 2013 The Polymer Authors. All rights reserved. |
| 5405 // Use of this source code is goverened by a BSD-style | 5607 // Use of this source code is goverened by a BSD-style |
| 5406 // license that can be found in the LICENSE file. | 5608 // license that can be found in the LICENSE file. |
| 5407 | 5609 |
| 5408 (function(scope) { | 5610 (function(scope) { |
| 5409 'use strict'; | 5611 'use strict'; |
| 5410 | 5612 |
| 5411 var HTMLElement = scope.wrappers.HTMLElement; | 5613 var HTMLElement = scope.wrappers.HTMLElement; |
| 5412 var mixin = scope.mixin; | 5614 var mixin = scope.mixin; |
| 5413 var registerWrapper = scope.registerWrapper; | 5615 var registerWrapper = scope.registerWrapper; |
| 5414 | 5616 |
| 5415 var OriginalHTMLContentElement = window.HTMLContentElement; | 5617 var OriginalHTMLContentElement = window.HTMLContentElement; |
| 5416 | 5618 |
| 5417 function HTMLContentElement(node) { | 5619 function HTMLContentElement(node) { |
| 5418 HTMLElement.call(this, node); | 5620 HTMLElement.call(this, node); |
| 5419 } | 5621 } |
| 5420 HTMLContentElement.prototype = Object.create(HTMLElement.prototype); | 5622 HTMLContentElement.prototype = Object.create(HTMLElement.prototype); |
| 5421 mixin(HTMLContentElement.prototype, { | 5623 mixin(HTMLContentElement.prototype, { |
| 5624 constructor: HTMLContentElement, |
| 5625 |
| 5422 get select() { | 5626 get select() { |
| 5423 return this.getAttribute('select'); | 5627 return this.getAttribute('select'); |
| 5424 }, | 5628 }, |
| 5425 set select(value) { | 5629 set select(value) { |
| 5426 this.setAttribute('select', value); | 5630 this.setAttribute('select', value); |
| 5427 }, | 5631 }, |
| 5428 | 5632 |
| 5429 setAttribute: function(n, v) { | 5633 setAttribute: function(n, v) { |
| 5430 HTMLElement.prototype.setAttribute.call(this, n, v); | 5634 HTMLElement.prototype.setAttribute.call(this, n, v); |
| 5431 if (String(n).toLowerCase() === 'select') | 5635 if (String(n).toLowerCase() === 'select') |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5532 var mixin = scope.mixin; | 5736 var mixin = scope.mixin; |
| 5533 var NodeList = scope.wrappers.NodeList; | 5737 var NodeList = scope.wrappers.NodeList; |
| 5534 var registerWrapper = scope.registerWrapper; | 5738 var registerWrapper = scope.registerWrapper; |
| 5535 | 5739 |
| 5536 var OriginalHTMLShadowElement = window.HTMLShadowElement; | 5740 var OriginalHTMLShadowElement = window.HTMLShadowElement; |
| 5537 | 5741 |
| 5538 function HTMLShadowElement(node) { | 5742 function HTMLShadowElement(node) { |
| 5539 HTMLElement.call(this, node); | 5743 HTMLElement.call(this, node); |
| 5540 } | 5744 } |
| 5541 HTMLShadowElement.prototype = Object.create(HTMLElement.prototype); | 5745 HTMLShadowElement.prototype = Object.create(HTMLElement.prototype); |
| 5746 HTMLShadowElement.prototype.constructor = HTMLShadowElement; |
| 5542 | 5747 |
| 5543 // getDistributedNodes is added in ShadowRenderer | 5748 // getDistributedNodes is added in ShadowRenderer |
| 5544 | 5749 |
| 5545 if (OriginalHTMLShadowElement) | 5750 if (OriginalHTMLShadowElement) |
| 5546 registerWrapper(OriginalHTMLShadowElement, HTMLShadowElement); | 5751 registerWrapper(OriginalHTMLShadowElement, HTMLShadowElement); |
| 5547 | 5752 |
| 5548 scope.wrappers.HTMLShadowElement = HTMLShadowElement; | 5753 scope.wrappers.HTMLShadowElement = HTMLShadowElement; |
| 5549 })(window.ShadowDOMPolyfill); | 5754 })(window.ShadowDOMPolyfill); |
| 5550 | 5755 |
| 5551 // Copyright 2013 The Polymer Authors. All rights reserved. | 5756 // Copyright 2013 The Polymer Authors. All rights reserved. |
| 5552 // Use of this source code is goverened by a BSD-style | 5757 // Use of this source code is goverened by a BSD-style |
| 5553 // license that can be found in the LICENSE file. | 5758 // license that can be found in the LICENSE file. |
| 5554 | 5759 |
| 5555 (function(scope) { | 5760 (function(scope) { |
| 5556 'use strict'; | 5761 'use strict'; |
| 5557 | 5762 |
| 5558 var HTMLElement = scope.wrappers.HTMLElement; | 5763 var HTMLElement = scope.wrappers.HTMLElement; |
| 5559 var mixin = scope.mixin; | 5764 var mixin = scope.mixin; |
| 5560 var registerWrapper = scope.registerWrapper; | 5765 var registerWrapper = scope.registerWrapper; |
| 5766 var unsafeUnwrap = scope.unsafeUnwrap; |
| 5561 var unwrap = scope.unwrap; | 5767 var unwrap = scope.unwrap; |
| 5562 var wrap = scope.wrap; | 5768 var wrap = scope.wrap; |
| 5563 | 5769 |
| 5564 var contentTable = new WeakMap(); | 5770 var contentTable = new WeakMap(); |
| 5565 var templateContentsOwnerTable = new WeakMap(); | 5771 var templateContentsOwnerTable = new WeakMap(); |
| 5566 | 5772 |
| 5567 // http://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/templates/index.html#
dfn-template-contents-owner | 5773 // http://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/templates/index.html#
dfn-template-contents-owner |
| 5568 function getTemplateContentsOwner(doc) { | 5774 function getTemplateContentsOwner(doc) { |
| 5569 if (!doc.defaultView) | 5775 if (!doc.defaultView) |
| 5570 return doc; | 5776 return doc; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 5597 function HTMLTemplateElement(node) { | 5803 function HTMLTemplateElement(node) { |
| 5598 HTMLElement.call(this, node); | 5804 HTMLElement.call(this, node); |
| 5599 if (!OriginalHTMLTemplateElement) { | 5805 if (!OriginalHTMLTemplateElement) { |
| 5600 var content = extractContent(node); | 5806 var content = extractContent(node); |
| 5601 contentTable.set(this, wrap(content)); | 5807 contentTable.set(this, wrap(content)); |
| 5602 } | 5808 } |
| 5603 } | 5809 } |
| 5604 HTMLTemplateElement.prototype = Object.create(HTMLElement.prototype); | 5810 HTMLTemplateElement.prototype = Object.create(HTMLElement.prototype); |
| 5605 | 5811 |
| 5606 mixin(HTMLTemplateElement.prototype, { | 5812 mixin(HTMLTemplateElement.prototype, { |
| 5813 constructor: HTMLTemplateElement, |
| 5607 get content() { | 5814 get content() { |
| 5608 if (OriginalHTMLTemplateElement) | 5815 if (OriginalHTMLTemplateElement) |
| 5609 return wrap(this.impl.content); | 5816 return wrap(unsafeUnwrap(this).content); |
| 5610 return contentTable.get(this); | 5817 return contentTable.get(this); |
| 5611 }, | 5818 }, |
| 5612 | 5819 |
| 5613 // TODO(arv): cloneNode needs to clone content. | 5820 // TODO(arv): cloneNode needs to clone content. |
| 5614 | 5821 |
| 5615 }); | 5822 }); |
| 5616 | 5823 |
| 5617 if (OriginalHTMLTemplateElement) | 5824 if (OriginalHTMLTemplateElement) |
| 5618 registerWrapper(OriginalHTMLTemplateElement, HTMLTemplateElement); | 5825 registerWrapper(OriginalHTMLTemplateElement, HTMLTemplateElement); |
| 5619 | 5826 |
| 5620 scope.wrappers.HTMLTemplateElement = HTMLTemplateElement; | 5827 scope.wrappers.HTMLTemplateElement = HTMLTemplateElement; |
| 5621 })(window.ShadowDOMPolyfill); | 5828 })(window.ShadowDOMPolyfill); |
| 5622 | 5829 |
| 5623 // Copyright 2013 The Polymer Authors. All rights reserved. | 5830 // Copyright 2013 The Polymer Authors. All rights reserved. |
| 5624 // Use of this source code is goverened by a BSD-style | 5831 // Use of this source code is goverened by a BSD-style |
| 5625 // license that can be found in the LICENSE file. | 5832 // license that can be found in the LICENSE file. |
| 5626 | 5833 |
| 5627 (function(scope) { | 5834 (function(scope) { |
| 5628 'use strict'; | 5835 'use strict'; |
| 5629 | 5836 |
| 5630 var HTMLElement = scope.wrappers.HTMLElement; | 5837 var HTMLElement = scope.wrappers.HTMLElement; |
| 5631 var registerWrapper = scope.registerWrapper; | 5838 var registerWrapper = scope.registerWrapper; |
| 5632 | 5839 |
| 5633 var OriginalHTMLMediaElement = window.HTMLMediaElement; | 5840 var OriginalHTMLMediaElement = window.HTMLMediaElement; |
| 5634 | 5841 |
| 5842 if (!OriginalHTMLMediaElement) return; |
| 5843 |
| 5635 function HTMLMediaElement(node) { | 5844 function HTMLMediaElement(node) { |
| 5636 HTMLElement.call(this, node); | 5845 HTMLElement.call(this, node); |
| 5637 } | 5846 } |
| 5638 HTMLMediaElement.prototype = Object.create(HTMLElement.prototype); | 5847 HTMLMediaElement.prototype = Object.create(HTMLElement.prototype); |
| 5639 | 5848 |
| 5640 registerWrapper(OriginalHTMLMediaElement, HTMLMediaElement, | 5849 registerWrapper(OriginalHTMLMediaElement, HTMLMediaElement, |
| 5641 document.createElement('audio')); | 5850 document.createElement('audio')); |
| 5642 | 5851 |
| 5643 scope.wrappers.HTMLMediaElement = HTMLMediaElement; | 5852 scope.wrappers.HTMLMediaElement = HTMLMediaElement; |
| 5644 })(window.ShadowDOMPolyfill); | 5853 })(window.ShadowDOMPolyfill); |
| 5645 | 5854 |
| 5646 // Copyright 2013 The Polymer Authors. All rights reserved. | 5855 // Copyright 2013 The Polymer Authors. All rights reserved. |
| 5647 // Use of this source code is goverened by a BSD-style | 5856 // Use of this source code is goverened by a BSD-style |
| 5648 // license that can be found in the LICENSE file. | 5857 // license that can be found in the LICENSE file. |
| 5649 | 5858 |
| 5650 (function(scope) { | 5859 (function(scope) { |
| 5651 'use strict'; | 5860 'use strict'; |
| 5652 | 5861 |
| 5653 var HTMLMediaElement = scope.wrappers.HTMLMediaElement; | 5862 var HTMLMediaElement = scope.wrappers.HTMLMediaElement; |
| 5654 var registerWrapper = scope.registerWrapper; | 5863 var registerWrapper = scope.registerWrapper; |
| 5655 var unwrap = scope.unwrap; | 5864 var unwrap = scope.unwrap; |
| 5656 var rewrap = scope.rewrap; | 5865 var rewrap = scope.rewrap; |
| 5657 | 5866 |
| 5658 var OriginalHTMLAudioElement = window.HTMLAudioElement; | 5867 var OriginalHTMLAudioElement = window.HTMLAudioElement; |
| 5659 | 5868 |
| 5869 if (!OriginalHTMLAudioElement) return; |
| 5870 |
| 5660 function HTMLAudioElement(node) { | 5871 function HTMLAudioElement(node) { |
| 5661 HTMLMediaElement.call(this, node); | 5872 HTMLMediaElement.call(this, node); |
| 5662 } | 5873 } |
| 5663 HTMLAudioElement.prototype = Object.create(HTMLMediaElement.prototype); | 5874 HTMLAudioElement.prototype = Object.create(HTMLMediaElement.prototype); |
| 5664 | 5875 |
| 5665 registerWrapper(OriginalHTMLAudioElement, HTMLAudioElement, | 5876 registerWrapper(OriginalHTMLAudioElement, HTMLAudioElement, |
| 5666 document.createElement('audio')); | 5877 document.createElement('audio')); |
| 5667 | 5878 |
| 5668 function Audio(src) { | 5879 function Audio(src) { |
| 5669 if (!(this instanceof Audio)) { | 5880 if (!(this instanceof Audio)) { |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5882 var unwrap = scope.unwrap; | 6093 var unwrap = scope.unwrap; |
| 5883 var wrap = scope.wrap; | 6094 var wrap = scope.wrap; |
| 5884 | 6095 |
| 5885 var OriginalHTMLTableSectionElement = window.HTMLTableSectionElement; | 6096 var OriginalHTMLTableSectionElement = window.HTMLTableSectionElement; |
| 5886 | 6097 |
| 5887 function HTMLTableSectionElement(node) { | 6098 function HTMLTableSectionElement(node) { |
| 5888 HTMLElement.call(this, node); | 6099 HTMLElement.call(this, node); |
| 5889 } | 6100 } |
| 5890 HTMLTableSectionElement.prototype = Object.create(HTMLElement.prototype); | 6101 HTMLTableSectionElement.prototype = Object.create(HTMLElement.prototype); |
| 5891 mixin(HTMLTableSectionElement.prototype, { | 6102 mixin(HTMLTableSectionElement.prototype, { |
| 6103 constructor: HTMLTableSectionElement, |
| 5892 get rows() { | 6104 get rows() { |
| 5893 return wrapHTMLCollection(unwrap(this).rows); | 6105 return wrapHTMLCollection(unwrap(this).rows); |
| 5894 }, | 6106 }, |
| 5895 insertRow: function(index) { | 6107 insertRow: function(index) { |
| 5896 return wrap(unwrap(this).insertRow(index)); | 6108 return wrap(unwrap(this).insertRow(index)); |
| 5897 } | 6109 } |
| 5898 }); | 6110 }); |
| 5899 | 6111 |
| 5900 registerWrapper(OriginalHTMLTableSectionElement, HTMLTableSectionElement, | 6112 registerWrapper(OriginalHTMLTableSectionElement, HTMLTableSectionElement, |
| 5901 document.createElement('thead')); | 6113 document.createElement('thead')); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6052 // Copyright 2014 The Polymer Authors. All rights reserved. | 6264 // Copyright 2014 The Polymer Authors. All rights reserved. |
| 6053 // Use of this source code is goverened by a BSD-style | 6265 // Use of this source code is goverened by a BSD-style |
| 6054 // license that can be found in the LICENSE file. | 6266 // license that can be found in the LICENSE file. |
| 6055 | 6267 |
| 6056 (function(scope) { | 6268 (function(scope) { |
| 6057 'use strict'; | 6269 'use strict'; |
| 6058 | 6270 |
| 6059 var EventTarget = scope.wrappers.EventTarget; | 6271 var EventTarget = scope.wrappers.EventTarget; |
| 6060 var mixin = scope.mixin; | 6272 var mixin = scope.mixin; |
| 6061 var registerWrapper = scope.registerWrapper; | 6273 var registerWrapper = scope.registerWrapper; |
| 6274 var unsafeUnwrap = scope.unsafeUnwrap; |
| 6062 var wrap = scope.wrap; | 6275 var wrap = scope.wrap; |
| 6063 | 6276 |
| 6064 var OriginalSVGElementInstance = window.SVGElementInstance; | 6277 var OriginalSVGElementInstance = window.SVGElementInstance; |
| 6065 if (!OriginalSVGElementInstance) | 6278 if (!OriginalSVGElementInstance) |
| 6066 return; | 6279 return; |
| 6067 | 6280 |
| 6068 function SVGElementInstance(impl) { | 6281 function SVGElementInstance(impl) { |
| 6069 EventTarget.call(this, impl); | 6282 EventTarget.call(this, impl); |
| 6070 } | 6283 } |
| 6071 | 6284 |
| 6072 SVGElementInstance.prototype = Object.create(EventTarget.prototype); | 6285 SVGElementInstance.prototype = Object.create(EventTarget.prototype); |
| 6073 mixin(SVGElementInstance.prototype, { | 6286 mixin(SVGElementInstance.prototype, { |
| 6074 /** @type {SVGElement} */ | 6287 /** @type {SVGElement} */ |
| 6075 get correspondingElement() { | 6288 get correspondingElement() { |
| 6076 return wrap(this.impl.correspondingElement); | 6289 return wrap(unsafeUnwrap(this).correspondingElement); |
| 6077 }, | 6290 }, |
| 6078 | 6291 |
| 6079 /** @type {SVGUseElement} */ | 6292 /** @type {SVGUseElement} */ |
| 6080 get correspondingUseElement() { | 6293 get correspondingUseElement() { |
| 6081 return wrap(this.impl.correspondingUseElement); | 6294 return wrap(unsafeUnwrap(this).correspondingUseElement); |
| 6082 }, | 6295 }, |
| 6083 | 6296 |
| 6084 /** @type {SVGElementInstance} */ | 6297 /** @type {SVGElementInstance} */ |
| 6085 get parentNode() { | 6298 get parentNode() { |
| 6086 return wrap(this.impl.parentNode); | 6299 return wrap(unsafeUnwrap(this).parentNode); |
| 6087 }, | 6300 }, |
| 6088 | 6301 |
| 6089 /** @type {SVGElementInstanceList} */ | 6302 /** @type {SVGElementInstanceList} */ |
| 6090 get childNodes() { | 6303 get childNodes() { |
| 6091 throw new Error('Not implemented'); | 6304 throw new Error('Not implemented'); |
| 6092 }, | 6305 }, |
| 6093 | 6306 |
| 6094 /** @type {SVGElementInstance} */ | 6307 /** @type {SVGElementInstance} */ |
| 6095 get firstChild() { | 6308 get firstChild() { |
| 6096 return wrap(this.impl.firstChild); | 6309 return wrap(unsafeUnwrap(this).firstChild); |
| 6097 }, | 6310 }, |
| 6098 | 6311 |
| 6099 /** @type {SVGElementInstance} */ | 6312 /** @type {SVGElementInstance} */ |
| 6100 get lastChild() { | 6313 get lastChild() { |
| 6101 return wrap(this.impl.lastChild); | 6314 return wrap(unsafeUnwrap(this).lastChild); |
| 6102 }, | 6315 }, |
| 6103 | 6316 |
| 6104 /** @type {SVGElementInstance} */ | 6317 /** @type {SVGElementInstance} */ |
| 6105 get previousSibling() { | 6318 get previousSibling() { |
| 6106 return wrap(this.impl.previousSibling); | 6319 return wrap(unsafeUnwrap(this).previousSibling); |
| 6107 }, | 6320 }, |
| 6108 | 6321 |
| 6109 /** @type {SVGElementInstance} */ | 6322 /** @type {SVGElementInstance} */ |
| 6110 get nextSibling() { | 6323 get nextSibling() { |
| 6111 return wrap(this.impl.nextSibling); | 6324 return wrap(unsafeUnwrap(this).nextSibling); |
| 6112 } | 6325 } |
| 6113 }); | 6326 }); |
| 6114 | 6327 |
| 6115 registerWrapper(OriginalSVGElementInstance, SVGElementInstance); | 6328 registerWrapper(OriginalSVGElementInstance, SVGElementInstance); |
| 6116 | 6329 |
| 6117 scope.wrappers.SVGElementInstance = SVGElementInstance; | 6330 scope.wrappers.SVGElementInstance = SVGElementInstance; |
| 6118 })(window.ShadowDOMPolyfill); | 6331 })(window.ShadowDOMPolyfill); |
| 6119 | 6332 |
| 6120 // Copyright 2013 The Polymer Authors. All rights reserved. | 6333 // Copyright 2013 The Polymer Authors. All rights reserved. |
| 6121 // Use of this source code is goverened by a BSD-style | 6334 // Use of this source code is goverened by a BSD-style |
| 6122 // license that can be found in the LICENSE file. | 6335 // license that can be found in the LICENSE file. |
| 6123 | 6336 |
| 6124 (function(scope) { | 6337 (function(scope) { |
| 6125 'use strict'; | 6338 'use strict'; |
| 6126 | 6339 |
| 6127 var mixin = scope.mixin; | 6340 var mixin = scope.mixin; |
| 6128 var registerWrapper = scope.registerWrapper; | 6341 var registerWrapper = scope.registerWrapper; |
| 6342 var setWrapper = scope.setWrapper; |
| 6343 var unsafeUnwrap = scope.unsafeUnwrap; |
| 6129 var unwrap = scope.unwrap; | 6344 var unwrap = scope.unwrap; |
| 6130 var unwrapIfNeeded = scope.unwrapIfNeeded; | 6345 var unwrapIfNeeded = scope.unwrapIfNeeded; |
| 6131 var wrap = scope.wrap; | 6346 var wrap = scope.wrap; |
| 6132 | 6347 |
| 6133 var OriginalCanvasRenderingContext2D = window.CanvasRenderingContext2D; | 6348 var OriginalCanvasRenderingContext2D = window.CanvasRenderingContext2D; |
| 6134 | 6349 |
| 6135 function CanvasRenderingContext2D(impl) { | 6350 function CanvasRenderingContext2D(impl) { |
| 6136 this.impl = impl; | 6351 setWrapper(impl, this); |
| 6137 } | 6352 } |
| 6138 | 6353 |
| 6139 mixin(CanvasRenderingContext2D.prototype, { | 6354 mixin(CanvasRenderingContext2D.prototype, { |
| 6140 get canvas() { | 6355 get canvas() { |
| 6141 return wrap(this.impl.canvas); | 6356 return wrap(unsafeUnwrap(this).canvas); |
| 6142 }, | 6357 }, |
| 6143 | 6358 |
| 6144 drawImage: function() { | 6359 drawImage: function() { |
| 6145 arguments[0] = unwrapIfNeeded(arguments[0]); | 6360 arguments[0] = unwrapIfNeeded(arguments[0]); |
| 6146 this.impl.drawImage.apply(this.impl, arguments); | 6361 unsafeUnwrap(this).drawImage.apply(unsafeUnwrap(this), arguments); |
| 6147 }, | 6362 }, |
| 6148 | 6363 |
| 6149 createPattern: function() { | 6364 createPattern: function() { |
| 6150 arguments[0] = unwrap(arguments[0]); | 6365 arguments[0] = unwrap(arguments[0]); |
| 6151 return this.impl.createPattern.apply(this.impl, arguments); | 6366 return unsafeUnwrap(this).createPattern.apply(unsafeUnwrap(this), argument
s); |
| 6152 } | 6367 } |
| 6153 }); | 6368 }); |
| 6154 | 6369 |
| 6155 registerWrapper(OriginalCanvasRenderingContext2D, CanvasRenderingContext2D, | 6370 registerWrapper(OriginalCanvasRenderingContext2D, CanvasRenderingContext2D, |
| 6156 document.createElement('canvas').getContext('2d')); | 6371 document.createElement('canvas').getContext('2d')); |
| 6157 | 6372 |
| 6158 scope.wrappers.CanvasRenderingContext2D = CanvasRenderingContext2D; | 6373 scope.wrappers.CanvasRenderingContext2D = CanvasRenderingContext2D; |
| 6159 })(window.ShadowDOMPolyfill); | 6374 })(window.ShadowDOMPolyfill); |
| 6160 | 6375 |
| 6161 // Copyright 2013 The Polymer Authors. All rights reserved. | 6376 // Copyright 2013 The Polymer Authors. All rights reserved. |
| 6162 // Use of this source code is goverened by a BSD-style | 6377 // Use of this source code is goverened by a BSD-style |
| 6163 // license that can be found in the LICENSE file. | 6378 // license that can be found in the LICENSE file. |
| 6164 | 6379 |
| 6165 (function(scope) { | 6380 (function(scope) { |
| 6166 'use strict'; | 6381 'use strict'; |
| 6167 | 6382 |
| 6168 var mixin = scope.mixin; | 6383 var mixin = scope.mixin; |
| 6169 var registerWrapper = scope.registerWrapper; | 6384 var registerWrapper = scope.registerWrapper; |
| 6385 var setWrapper = scope.setWrapper; |
| 6386 var unsafeUnwrap = scope.unsafeUnwrap; |
| 6170 var unwrapIfNeeded = scope.unwrapIfNeeded; | 6387 var unwrapIfNeeded = scope.unwrapIfNeeded; |
| 6171 var wrap = scope.wrap; | 6388 var wrap = scope.wrap; |
| 6172 | 6389 |
| 6173 var OriginalWebGLRenderingContext = window.WebGLRenderingContext; | 6390 var OriginalWebGLRenderingContext = window.WebGLRenderingContext; |
| 6174 | 6391 |
| 6175 // IE10 does not have WebGL. | 6392 // IE10 does not have WebGL. |
| 6176 if (!OriginalWebGLRenderingContext) | 6393 if (!OriginalWebGLRenderingContext) |
| 6177 return; | 6394 return; |
| 6178 | 6395 |
| 6179 function WebGLRenderingContext(impl) { | 6396 function WebGLRenderingContext(impl) { |
| 6180 this.impl = impl; | 6397 setWrapper(impl, this); |
| 6181 } | 6398 } |
| 6182 | 6399 |
| 6183 mixin(WebGLRenderingContext.prototype, { | 6400 mixin(WebGLRenderingContext.prototype, { |
| 6184 get canvas() { | 6401 get canvas() { |
| 6185 return wrap(this.impl.canvas); | 6402 return wrap(unsafeUnwrap(this).canvas); |
| 6186 }, | 6403 }, |
| 6187 | 6404 |
| 6188 texImage2D: function() { | 6405 texImage2D: function() { |
| 6189 arguments[5] = unwrapIfNeeded(arguments[5]); | 6406 arguments[5] = unwrapIfNeeded(arguments[5]); |
| 6190 this.impl.texImage2D.apply(this.impl, arguments); | 6407 unsafeUnwrap(this).texImage2D.apply(unsafeUnwrap(this), arguments); |
| 6191 }, | 6408 }, |
| 6192 | 6409 |
| 6193 texSubImage2D: function() { | 6410 texSubImage2D: function() { |
| 6194 arguments[6] = unwrapIfNeeded(arguments[6]); | 6411 arguments[6] = unwrapIfNeeded(arguments[6]); |
| 6195 this.impl.texSubImage2D.apply(this.impl, arguments); | 6412 unsafeUnwrap(this).texSubImage2D.apply(unsafeUnwrap(this), arguments); |
| 6196 } | 6413 } |
| 6197 }); | 6414 }); |
| 6198 | 6415 |
| 6199 // Blink/WebKit has broken DOM bindings. Usually we would create an instance | 6416 // Blink/WebKit has broken DOM bindings. Usually we would create an instance |
| 6200 // of the object and pass it into registerWrapper as a "blueprint" but | 6417 // of the object and pass it into registerWrapper as a "blueprint" but |
| 6201 // creating WebGL contexts is expensive and might fail so we use a dummy | 6418 // creating WebGL contexts is expensive and might fail so we use a dummy |
| 6202 // object with dummy instance properties for these broken browsers. | 6419 // object with dummy instance properties for these broken browsers. |
| 6203 var instanceProperties = /WebKit/.test(navigator.userAgent) ? | 6420 var instanceProperties = /WebKit/.test(navigator.userAgent) ? |
| 6204 {drawingBufferHeight: null, drawingBufferWidth: null} : {}; | 6421 {drawingBufferHeight: null, drawingBufferWidth: null} : {}; |
| 6205 | 6422 |
| 6206 registerWrapper(OriginalWebGLRenderingContext, WebGLRenderingContext, | 6423 registerWrapper(OriginalWebGLRenderingContext, WebGLRenderingContext, |
| 6207 instanceProperties); | 6424 instanceProperties); |
| 6208 | 6425 |
| 6209 scope.wrappers.WebGLRenderingContext = WebGLRenderingContext; | 6426 scope.wrappers.WebGLRenderingContext = WebGLRenderingContext; |
| 6210 })(window.ShadowDOMPolyfill); | 6427 })(window.ShadowDOMPolyfill); |
| 6211 | 6428 |
| 6212 // Copyright 2013 The Polymer Authors. All rights reserved. | 6429 // Copyright 2013 The Polymer Authors. All rights reserved. |
| 6213 // Use of this source code is goverened by a BSD-style | 6430 // Use of this source code is goverened by a BSD-style |
| 6214 // license that can be found in the LICENSE file. | 6431 // license that can be found in the LICENSE file. |
| 6215 | 6432 |
| 6216 (function(scope) { | 6433 (function(scope) { |
| 6217 'use strict'; | 6434 'use strict'; |
| 6218 | 6435 |
| 6219 var registerWrapper = scope.registerWrapper; | 6436 var registerWrapper = scope.registerWrapper; |
| 6437 var setWrapper = scope.setWrapper; |
| 6438 var unsafeUnwrap = scope.unsafeUnwrap; |
| 6220 var unwrap = scope.unwrap; | 6439 var unwrap = scope.unwrap; |
| 6221 var unwrapIfNeeded = scope.unwrapIfNeeded; | 6440 var unwrapIfNeeded = scope.unwrapIfNeeded; |
| 6222 var wrap = scope.wrap; | 6441 var wrap = scope.wrap; |
| 6223 | 6442 |
| 6224 var OriginalRange = window.Range; | 6443 var OriginalRange = window.Range; |
| 6225 | 6444 |
| 6226 function Range(impl) { | 6445 function Range(impl) { |
| 6227 this.impl = impl; | 6446 setWrapper(impl, this); |
| 6228 } | 6447 } |
| 6229 Range.prototype = { | 6448 Range.prototype = { |
| 6230 get startContainer() { | 6449 get startContainer() { |
| 6231 return wrap(this.impl.startContainer); | 6450 return wrap(unsafeUnwrap(this).startContainer); |
| 6232 }, | 6451 }, |
| 6233 get endContainer() { | 6452 get endContainer() { |
| 6234 return wrap(this.impl.endContainer); | 6453 return wrap(unsafeUnwrap(this).endContainer); |
| 6235 }, | 6454 }, |
| 6236 get commonAncestorContainer() { | 6455 get commonAncestorContainer() { |
| 6237 return wrap(this.impl.commonAncestorContainer); | 6456 return wrap(unsafeUnwrap(this).commonAncestorContainer); |
| 6238 }, | 6457 }, |
| 6239 setStart: function(refNode,offset) { | 6458 setStart: function(refNode,offset) { |
| 6240 this.impl.setStart(unwrapIfNeeded(refNode), offset); | 6459 unsafeUnwrap(this).setStart(unwrapIfNeeded(refNode), offset); |
| 6241 }, | 6460 }, |
| 6242 setEnd: function(refNode,offset) { | 6461 setEnd: function(refNode,offset) { |
| 6243 this.impl.setEnd(unwrapIfNeeded(refNode), offset); | 6462 unsafeUnwrap(this).setEnd(unwrapIfNeeded(refNode), offset); |
| 6244 }, | 6463 }, |
| 6245 setStartBefore: function(refNode) { | 6464 setStartBefore: function(refNode) { |
| 6246 this.impl.setStartBefore(unwrapIfNeeded(refNode)); | 6465 unsafeUnwrap(this).setStartBefore(unwrapIfNeeded(refNode)); |
| 6247 }, | 6466 }, |
| 6248 setStartAfter: function(refNode) { | 6467 setStartAfter: function(refNode) { |
| 6249 this.impl.setStartAfter(unwrapIfNeeded(refNode)); | 6468 unsafeUnwrap(this).setStartAfter(unwrapIfNeeded(refNode)); |
| 6250 }, | 6469 }, |
| 6251 setEndBefore: function(refNode) { | 6470 setEndBefore: function(refNode) { |
| 6252 this.impl.setEndBefore(unwrapIfNeeded(refNode)); | 6471 unsafeUnwrap(this).setEndBefore(unwrapIfNeeded(refNode)); |
| 6253 }, | 6472 }, |
| 6254 setEndAfter: function(refNode) { | 6473 setEndAfter: function(refNode) { |
| 6255 this.impl.setEndAfter(unwrapIfNeeded(refNode)); | 6474 unsafeUnwrap(this).setEndAfter(unwrapIfNeeded(refNode)); |
| 6256 }, | 6475 }, |
| 6257 selectNode: function(refNode) { | 6476 selectNode: function(refNode) { |
| 6258 this.impl.selectNode(unwrapIfNeeded(refNode)); | 6477 unsafeUnwrap(this).selectNode(unwrapIfNeeded(refNode)); |
| 6259 }, | 6478 }, |
| 6260 selectNodeContents: function(refNode) { | 6479 selectNodeContents: function(refNode) { |
| 6261 this.impl.selectNodeContents(unwrapIfNeeded(refNode)); | 6480 unsafeUnwrap(this).selectNodeContents(unwrapIfNeeded(refNode)); |
| 6262 }, | 6481 }, |
| 6263 compareBoundaryPoints: function(how, sourceRange) { | 6482 compareBoundaryPoints: function(how, sourceRange) { |
| 6264 return this.impl.compareBoundaryPoints(how, unwrap(sourceRange)); | 6483 return unsafeUnwrap(this).compareBoundaryPoints(how, unwrap(sourceRange)); |
| 6265 }, | 6484 }, |
| 6266 extractContents: function() { | 6485 extractContents: function() { |
| 6267 return wrap(this.impl.extractContents()); | 6486 return wrap(unsafeUnwrap(this).extractContents()); |
| 6268 }, | 6487 }, |
| 6269 cloneContents: function() { | 6488 cloneContents: function() { |
| 6270 return wrap(this.impl.cloneContents()); | 6489 return wrap(unsafeUnwrap(this).cloneContents()); |
| 6271 }, | 6490 }, |
| 6272 insertNode: function(node) { | 6491 insertNode: function(node) { |
| 6273 this.impl.insertNode(unwrapIfNeeded(node)); | 6492 unsafeUnwrap(this).insertNode(unwrapIfNeeded(node)); |
| 6274 }, | 6493 }, |
| 6275 surroundContents: function(newParent) { | 6494 surroundContents: function(newParent) { |
| 6276 this.impl.surroundContents(unwrapIfNeeded(newParent)); | 6495 unsafeUnwrap(this).surroundContents(unwrapIfNeeded(newParent)); |
| 6277 }, | 6496 }, |
| 6278 cloneRange: function() { | 6497 cloneRange: function() { |
| 6279 return wrap(this.impl.cloneRange()); | 6498 return wrap(unsafeUnwrap(this).cloneRange()); |
| 6280 }, | 6499 }, |
| 6281 isPointInRange: function(node, offset) { | 6500 isPointInRange: function(node, offset) { |
| 6282 return this.impl.isPointInRange(unwrapIfNeeded(node), offset); | 6501 return unsafeUnwrap(this).isPointInRange(unwrapIfNeeded(node), offset); |
| 6283 }, | 6502 }, |
| 6284 comparePoint: function(node, offset) { | 6503 comparePoint: function(node, offset) { |
| 6285 return this.impl.comparePoint(unwrapIfNeeded(node), offset); | 6504 return unsafeUnwrap(this).comparePoint(unwrapIfNeeded(node), offset); |
| 6286 }, | 6505 }, |
| 6287 intersectsNode: function(node) { | 6506 intersectsNode: function(node) { |
| 6288 return this.impl.intersectsNode(unwrapIfNeeded(node)); | 6507 return unsafeUnwrap(this).intersectsNode(unwrapIfNeeded(node)); |
| 6289 }, | 6508 }, |
| 6290 toString: function() { | 6509 toString: function() { |
| 6291 return this.impl.toString(); | 6510 return unsafeUnwrap(this).toString(); |
| 6292 } | 6511 } |
| 6293 }; | 6512 }; |
| 6294 | 6513 |
| 6295 // IE9 does not have createContextualFragment. | 6514 // IE9 does not have createContextualFragment. |
| 6296 if (OriginalRange.prototype.createContextualFragment) { | 6515 if (OriginalRange.prototype.createContextualFragment) { |
| 6297 Range.prototype.createContextualFragment = function(html) { | 6516 Range.prototype.createContextualFragment = function(html) { |
| 6298 return wrap(this.impl.createContextualFragment(html)); | 6517 return wrap(unsafeUnwrap(this).createContextualFragment(html)); |
| 6299 }; | 6518 }; |
| 6300 } | 6519 } |
| 6301 | 6520 |
| 6302 registerWrapper(window.Range, Range, document.createRange()); | 6521 registerWrapper(window.Range, Range, document.createRange()); |
| 6303 | 6522 |
| 6304 scope.wrappers.Range = Range; | 6523 scope.wrappers.Range = Range; |
| 6305 | 6524 |
| 6306 })(window.ShadowDOMPolyfill); | 6525 })(window.ShadowDOMPolyfill); |
| 6307 | 6526 |
| 6308 // Copyright 2013 The Polymer Authors. All rights reserved. | 6527 // Copyright 2013 The Polymer Authors. All rights reserved. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 6338 'use strict'; | 6557 'use strict'; |
| 6339 | 6558 |
| 6340 var DocumentFragment = scope.wrappers.DocumentFragment; | 6559 var DocumentFragment = scope.wrappers.DocumentFragment; |
| 6341 var TreeScope = scope.TreeScope; | 6560 var TreeScope = scope.TreeScope; |
| 6342 var elementFromPoint = scope.elementFromPoint; | 6561 var elementFromPoint = scope.elementFromPoint; |
| 6343 var getInnerHTML = scope.getInnerHTML; | 6562 var getInnerHTML = scope.getInnerHTML; |
| 6344 var getTreeScope = scope.getTreeScope; | 6563 var getTreeScope = scope.getTreeScope; |
| 6345 var mixin = scope.mixin; | 6564 var mixin = scope.mixin; |
| 6346 var rewrap = scope.rewrap; | 6565 var rewrap = scope.rewrap; |
| 6347 var setInnerHTML = scope.setInnerHTML; | 6566 var setInnerHTML = scope.setInnerHTML; |
| 6567 var unsafeUnwrap = scope.unsafeUnwrap; |
| 6348 var unwrap = scope.unwrap; | 6568 var unwrap = scope.unwrap; |
| 6349 | 6569 |
| 6350 var shadowHostTable = new WeakMap(); | 6570 var shadowHostTable = new WeakMap(); |
| 6351 var nextOlderShadowTreeTable = new WeakMap(); | 6571 var nextOlderShadowTreeTable = new WeakMap(); |
| 6352 | 6572 |
| 6353 var spaceCharRe = /[ \t\n\r\f]/; | 6573 var spaceCharRe = /[ \t\n\r\f]/; |
| 6354 | 6574 |
| 6355 function ShadowRoot(hostWrapper) { | 6575 function ShadowRoot(hostWrapper) { |
| 6356 var node = unwrap(hostWrapper.impl.ownerDocument.createDocumentFragment()); | 6576 var node = unwrap(unsafeUnwrap(hostWrapper).ownerDocument.createDocumentFrag
ment()); |
| 6357 DocumentFragment.call(this, node); | 6577 DocumentFragment.call(this, node); |
| 6358 | 6578 |
| 6359 // createDocumentFragment associates the node with a wrapper | 6579 // createDocumentFragment associates the node with a wrapper |
| 6360 // DocumentFragment instance. Override that. | 6580 // DocumentFragment instance. Override that. |
| 6361 rewrap(node, this); | 6581 rewrap(node, this); |
| 6362 | 6582 |
| 6363 var oldShadowRoot = hostWrapper.shadowRoot; | 6583 var oldShadowRoot = hostWrapper.shadowRoot; |
| 6364 nextOlderShadowTreeTable.set(this, oldShadowRoot); | 6584 nextOlderShadowTreeTable.set(this, oldShadowRoot); |
| 6365 | 6585 |
| 6366 this.treeScope_ = | 6586 this.treeScope_ = |
| 6367 new TreeScope(this, getTreeScope(oldShadowRoot || hostWrapper)); | 6587 new TreeScope(this, getTreeScope(oldShadowRoot || hostWrapper)); |
| 6368 | 6588 |
| 6369 shadowHostTable.set(this, hostWrapper); | 6589 shadowHostTable.set(this, hostWrapper); |
| 6370 } | 6590 } |
| 6371 ShadowRoot.prototype = Object.create(DocumentFragment.prototype); | 6591 ShadowRoot.prototype = Object.create(DocumentFragment.prototype); |
| 6372 mixin(ShadowRoot.prototype, { | 6592 mixin(ShadowRoot.prototype, { |
| 6593 constructor: ShadowRoot, |
| 6594 |
| 6373 get innerHTML() { | 6595 get innerHTML() { |
| 6374 return getInnerHTML(this); | 6596 return getInnerHTML(this); |
| 6375 }, | 6597 }, |
| 6376 set innerHTML(value) { | 6598 set innerHTML(value) { |
| 6377 setInnerHTML(this, value); | 6599 setInnerHTML(this, value); |
| 6378 this.invalidateShadowRenderer(); | 6600 this.invalidateShadowRenderer(); |
| 6379 }, | 6601 }, |
| 6380 | 6602 |
| 6381 get olderShadowRoot() { | 6603 get olderShadowRoot() { |
| 6382 return nextOlderShadowTreeTable.get(this) || null; | 6604 return nextOlderShadowTreeTable.get(this) || null; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6414 | 6636 |
| 6415 var Element = scope.wrappers.Element; | 6637 var Element = scope.wrappers.Element; |
| 6416 var HTMLContentElement = scope.wrappers.HTMLContentElement; | 6638 var HTMLContentElement = scope.wrappers.HTMLContentElement; |
| 6417 var HTMLShadowElement = scope.wrappers.HTMLShadowElement; | 6639 var HTMLShadowElement = scope.wrappers.HTMLShadowElement; |
| 6418 var Node = scope.wrappers.Node; | 6640 var Node = scope.wrappers.Node; |
| 6419 var ShadowRoot = scope.wrappers.ShadowRoot; | 6641 var ShadowRoot = scope.wrappers.ShadowRoot; |
| 6420 var assert = scope.assert; | 6642 var assert = scope.assert; |
| 6421 var getTreeScope = scope.getTreeScope; | 6643 var getTreeScope = scope.getTreeScope; |
| 6422 var mixin = scope.mixin; | 6644 var mixin = scope.mixin; |
| 6423 var oneOf = scope.oneOf; | 6645 var oneOf = scope.oneOf; |
| 6646 var unsafeUnwrap = scope.unsafeUnwrap; |
| 6424 var unwrap = scope.unwrap; | 6647 var unwrap = scope.unwrap; |
| 6425 var wrap = scope.wrap; | 6648 var wrap = scope.wrap; |
| 6426 | 6649 |
| 6427 /** | 6650 /** |
| 6428 * Updates the fields of a wrapper to a snapshot of the logical DOM as needed. | 6651 * Updates the fields of a wrapper to a snapshot of the logical DOM as needed. |
| 6429 * Up means parentNode | 6652 * Up means parentNode |
| 6430 * Sideways means previous and next sibling. | 6653 * Sideways means previous and next sibling. |
| 6431 * @param {!Node} wrapper | 6654 * @param {!Node} wrapper |
| 6432 */ | 6655 */ |
| 6433 function updateWrapperUpAndSideways(wrapper) { | 6656 function updateWrapperUpAndSideways(wrapper) { |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6884 }); | 7107 }); |
| 6885 | 7108 |
| 6886 // Pseudo selectors have been removed from the spec. | 7109 // Pseudo selectors have been removed from the spec. |
| 6887 }, | 7110 }, |
| 6888 | 7111 |
| 6889 dependsOnAttribute: function(name) { | 7112 dependsOnAttribute: function(name) { |
| 6890 return this.attributes[name]; | 7113 return this.attributes[name]; |
| 6891 }, | 7114 }, |
| 6892 | 7115 |
| 6893 associateNode: function(node) { | 7116 associateNode: function(node) { |
| 6894 node.impl.polymerShadowRenderer_ = this; | 7117 unsafeUnwrap(node).polymerShadowRenderer_ = this; |
| 6895 } | 7118 } |
| 6896 }; | 7119 }; |
| 6897 | 7120 |
| 6898 // http://w3c.github.io/webcomponents/spec/shadow/#dfn-pool-population-algorit
hm | 7121 // http://w3c.github.io/webcomponents/spec/shadow/#dfn-pool-population-algorit
hm |
| 6899 function poolPopulation(node) { | 7122 function poolPopulation(node) { |
| 6900 var pool = []; | 7123 var pool = []; |
| 6901 for (var child = node.firstChild; child; child = child.nextSibling) { | 7124 for (var child = node.firstChild; child; child = child.nextSibling) { |
| 6902 if (isInsertionPoint(child)) { | 7125 if (isInsertionPoint(child)) { |
| 6903 pool.push.apply(pool, getDistributedNodes(child)); | 7126 pool.push.apply(pool, getDistributedNodes(child)); |
| 6904 } else { | 7127 } else { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6938 // IE11 crashes when delete is used. | 7161 // IE11 crashes when delete is used. |
| 6939 destinationInsertionPointsTable.set(node, undefined); | 7162 destinationInsertionPointsTable.set(node, undefined); |
| 6940 } | 7163 } |
| 6941 | 7164 |
| 6942 // AllowedSelectors : | 7165 // AllowedSelectors : |
| 6943 // TypeSelector | 7166 // TypeSelector |
| 6944 // * | 7167 // * |
| 6945 // ClassSelector | 7168 // ClassSelector |
| 6946 // IDSelector | 7169 // IDSelector |
| 6947 // AttributeSelector | 7170 // AttributeSelector |
| 6948 var selectorStartCharRe = /^[*.#[a-zA-Z_|]/; | 7171 // negation |
| 7172 var selectorStartCharRe = /^(:not\()?[*.#[a-zA-Z_|]/; |
| 6949 | 7173 |
| 6950 function matches(node, contentElement) { | 7174 function matches(node, contentElement) { |
| 6951 var select = contentElement.getAttribute('select'); | 7175 var select = contentElement.getAttribute('select'); |
| 6952 if (!select) | 7176 if (!select) |
| 6953 return true; | 7177 return true; |
| 6954 | 7178 |
| 6955 // Here we know the select attribute is a non empty string. | 7179 // Here we know the select attribute is a non empty string. |
| 6956 select = select.trim(); | 7180 select = select.trim(); |
| 6957 if (!select) | 7181 if (!select) |
| 6958 return true; | 7182 return true; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7007 // - a new shadow root is created | 7231 // - a new shadow root is created |
| 7008 // - a direct child to a content/shadow element is added or removed | 7232 // - a direct child to a content/shadow element is added or removed |
| 7009 // - a sibling to a content/shadow element is added or removed | 7233 // - a sibling to a content/shadow element is added or removed |
| 7010 // - content[select] is changed | 7234 // - content[select] is changed |
| 7011 // - an attribute in a direct child to a host is modified | 7235 // - an attribute in a direct child to a host is modified |
| 7012 | 7236 |
| 7013 /** | 7237 /** |
| 7014 * This gets called when a node was added or removed to it. | 7238 * This gets called when a node was added or removed to it. |
| 7015 */ | 7239 */ |
| 7016 Node.prototype.invalidateShadowRenderer = function(force) { | 7240 Node.prototype.invalidateShadowRenderer = function(force) { |
| 7017 var renderer = this.impl.polymerShadowRenderer_; | 7241 var renderer = unsafeUnwrap(this).polymerShadowRenderer_; |
| 7018 if (renderer) { | 7242 if (renderer) { |
| 7019 renderer.invalidate(); | 7243 renderer.invalidate(); |
| 7020 return true; | 7244 return true; |
| 7021 } | 7245 } |
| 7022 | 7246 |
| 7023 return false; | 7247 return false; |
| 7024 }; | 7248 }; |
| 7025 | 7249 |
| 7026 HTMLContentElement.prototype.getDistributedNodes = | 7250 HTMLContentElement.prototype.getDistributedNodes = |
| 7027 HTMLShadowElement.prototype.getDistributedNodes = function() { | 7251 HTMLShadowElement.prototype.getDistributedNodes = function() { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 7038 | 7262 |
| 7039 HTMLContentElement.prototype.nodeIsInserted_ = | 7263 HTMLContentElement.prototype.nodeIsInserted_ = |
| 7040 HTMLShadowElement.prototype.nodeIsInserted_ = function() { | 7264 HTMLShadowElement.prototype.nodeIsInserted_ = function() { |
| 7041 // Invalidate old renderer if any. | 7265 // Invalidate old renderer if any. |
| 7042 this.invalidateShadowRenderer(); | 7266 this.invalidateShadowRenderer(); |
| 7043 | 7267 |
| 7044 var shadowRoot = getShadowRootAncestor(this); | 7268 var shadowRoot = getShadowRootAncestor(this); |
| 7045 var renderer; | 7269 var renderer; |
| 7046 if (shadowRoot) | 7270 if (shadowRoot) |
| 7047 renderer = getRendererForShadowRoot(shadowRoot); | 7271 renderer = getRendererForShadowRoot(shadowRoot); |
| 7048 this.impl.polymerShadowRenderer_ = renderer; | 7272 unsafeUnwrap(this).polymerShadowRenderer_ = renderer; |
| 7049 if (renderer) | 7273 if (renderer) |
| 7050 renderer.invalidate(); | 7274 renderer.invalidate(); |
| 7051 }; | 7275 }; |
| 7052 | 7276 |
| 7053 scope.getRendererForHost = getRendererForHost; | 7277 scope.getRendererForHost = getRendererForHost; |
| 7054 scope.getShadowTrees = getShadowTrees; | 7278 scope.getShadowTrees = getShadowTrees; |
| 7055 scope.renderAllPending = renderAllPending; | 7279 scope.renderAllPending = renderAllPending; |
| 7056 | 7280 |
| 7057 scope.getDestinationInsertionPoints = getDestinationInsertionPoints; | 7281 scope.getDestinationInsertionPoints = getDestinationInsertionPoints; |
| 7058 | 7282 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7120 })(window.ShadowDOMPolyfill); | 7344 })(window.ShadowDOMPolyfill); |
| 7121 | 7345 |
| 7122 // Copyright 2014 The Polymer Authors. All rights reserved. | 7346 // Copyright 2014 The Polymer Authors. All rights reserved. |
| 7123 // Use of this source code is goverened by a BSD-style | 7347 // Use of this source code is goverened by a BSD-style |
| 7124 // license that can be found in the LICENSE file. | 7348 // license that can be found in the LICENSE file. |
| 7125 | 7349 |
| 7126 (function(scope) { | 7350 (function(scope) { |
| 7127 'use strict'; | 7351 'use strict'; |
| 7128 | 7352 |
| 7129 var registerWrapper = scope.registerWrapper; | 7353 var registerWrapper = scope.registerWrapper; |
| 7354 var setWrapper = scope.setWrapper; |
| 7355 var unsafeUnwrap = scope.unsafeUnwrap; |
| 7130 var unwrap = scope.unwrap; | 7356 var unwrap = scope.unwrap; |
| 7131 var unwrapIfNeeded = scope.unwrapIfNeeded; | 7357 var unwrapIfNeeded = scope.unwrapIfNeeded; |
| 7132 var wrap = scope.wrap; | 7358 var wrap = scope.wrap; |
| 7133 | 7359 |
| 7134 var OriginalSelection = window.Selection; | 7360 var OriginalSelection = window.Selection; |
| 7135 | 7361 |
| 7136 function Selection(impl) { | 7362 function Selection(impl) { |
| 7137 this.impl = impl; | 7363 setWrapper(impl, this); |
| 7138 } | 7364 } |
| 7139 Selection.prototype = { | 7365 Selection.prototype = { |
| 7140 get anchorNode() { | 7366 get anchorNode() { |
| 7141 return wrap(this.impl.anchorNode); | 7367 return wrap(unsafeUnwrap(this).anchorNode); |
| 7142 }, | 7368 }, |
| 7143 get focusNode() { | 7369 get focusNode() { |
| 7144 return wrap(this.impl.focusNode); | 7370 return wrap(unsafeUnwrap(this).focusNode); |
| 7145 }, | 7371 }, |
| 7146 addRange: function(range) { | 7372 addRange: function(range) { |
| 7147 this.impl.addRange(unwrap(range)); | 7373 unsafeUnwrap(this).addRange(unwrap(range)); |
| 7148 }, | 7374 }, |
| 7149 collapse: function(node, index) { | 7375 collapse: function(node, index) { |
| 7150 this.impl.collapse(unwrapIfNeeded(node), index); | 7376 unsafeUnwrap(this).collapse(unwrapIfNeeded(node), index); |
| 7151 }, | 7377 }, |
| 7152 containsNode: function(node, allowPartial) { | 7378 containsNode: function(node, allowPartial) { |
| 7153 return this.impl.containsNode(unwrapIfNeeded(node), allowPartial); | 7379 return unsafeUnwrap(this).containsNode(unwrapIfNeeded(node), allowPartial)
; |
| 7154 }, | 7380 }, |
| 7155 extend: function(node, offset) { | 7381 extend: function(node, offset) { |
| 7156 this.impl.extend(unwrapIfNeeded(node), offset); | 7382 unsafeUnwrap(this).extend(unwrapIfNeeded(node), offset); |
| 7157 }, | 7383 }, |
| 7158 getRangeAt: function(index) { | 7384 getRangeAt: function(index) { |
| 7159 return wrap(this.impl.getRangeAt(index)); | 7385 return wrap(unsafeUnwrap(this).getRangeAt(index)); |
| 7160 }, | 7386 }, |
| 7161 removeRange: function(range) { | 7387 removeRange: function(range) { |
| 7162 this.impl.removeRange(unwrap(range)); | 7388 unsafeUnwrap(this).removeRange(unwrap(range)); |
| 7163 }, | 7389 }, |
| 7164 selectAllChildren: function(node) { | 7390 selectAllChildren: function(node) { |
| 7165 this.impl.selectAllChildren(unwrapIfNeeded(node)); | 7391 unsafeUnwrap(this).selectAllChildren(unwrapIfNeeded(node)); |
| 7166 }, | 7392 }, |
| 7167 toString: function() { | 7393 toString: function() { |
| 7168 return this.impl.toString(); | 7394 return unsafeUnwrap(this).toString(); |
| 7169 } | 7395 } |
| 7170 }; | 7396 }; |
| 7171 | 7397 |
| 7172 // WebKit extensions. Not implemented. | 7398 // WebKit extensions. Not implemented. |
| 7173 // readonly attribute Node baseNode; | 7399 // readonly attribute Node baseNode; |
| 7174 // readonly attribute long baseOffset; | 7400 // readonly attribute long baseOffset; |
| 7175 // readonly attribute Node extentNode; | 7401 // readonly attribute Node extentNode; |
| 7176 // readonly attribute long extentOffset; | 7402 // readonly attribute long extentOffset; |
| 7177 // [RaisesException] void setBaseAndExtent([Default=Undefined] optional Node b
aseNode, | 7403 // [RaisesException] void setBaseAndExtent([Default=Undefined] optional Node b
aseNode, |
| 7178 // [Default=Undefined] optional long baseOffset, | 7404 // [Default=Undefined] optional long baseOffset, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 7203 var TreeScope = scope.TreeScope; | 7429 var TreeScope = scope.TreeScope; |
| 7204 var cloneNode = scope.cloneNode; | 7430 var cloneNode = scope.cloneNode; |
| 7205 var defineWrapGetter = scope.defineWrapGetter; | 7431 var defineWrapGetter = scope.defineWrapGetter; |
| 7206 var elementFromPoint = scope.elementFromPoint; | 7432 var elementFromPoint = scope.elementFromPoint; |
| 7207 var forwardMethodsToWrapper = scope.forwardMethodsToWrapper; | 7433 var forwardMethodsToWrapper = scope.forwardMethodsToWrapper; |
| 7208 var matchesNames = scope.matchesNames; | 7434 var matchesNames = scope.matchesNames; |
| 7209 var mixin = scope.mixin; | 7435 var mixin = scope.mixin; |
| 7210 var registerWrapper = scope.registerWrapper; | 7436 var registerWrapper = scope.registerWrapper; |
| 7211 var renderAllPending = scope.renderAllPending; | 7437 var renderAllPending = scope.renderAllPending; |
| 7212 var rewrap = scope.rewrap; | 7438 var rewrap = scope.rewrap; |
| 7439 var setWrapper = scope.setWrapper; |
| 7440 var unsafeUnwrap = scope.unsafeUnwrap; |
| 7213 var unwrap = scope.unwrap; | 7441 var unwrap = scope.unwrap; |
| 7214 var wrap = scope.wrap; | 7442 var wrap = scope.wrap; |
| 7215 var wrapEventTargetMethods = scope.wrapEventTargetMethods; | 7443 var wrapEventTargetMethods = scope.wrapEventTargetMethods; |
| 7216 var wrapNodeList = scope.wrapNodeList; | 7444 var wrapNodeList = scope.wrapNodeList; |
| 7217 | 7445 |
| 7218 var implementationTable = new WeakMap(); | 7446 var implementationTable = new WeakMap(); |
| 7219 | 7447 |
| 7220 function Document(node) { | 7448 function Document(node) { |
| 7221 Node.call(this, node); | 7449 Node.call(this, node); |
| 7222 this.treeScope_ = new TreeScope(this, null); | 7450 this.treeScope_ = new TreeScope(this, null); |
| 7223 } | 7451 } |
| 7224 Document.prototype = Object.create(Node.prototype); | 7452 Document.prototype = Object.create(Node.prototype); |
| 7225 | 7453 |
| 7226 defineWrapGetter(Document, 'documentElement'); | 7454 defineWrapGetter(Document, 'documentElement'); |
| 7227 | 7455 |
| 7228 // Conceptually both body and head can be in a shadow but suporting that seems | 7456 // Conceptually both body and head can be in a shadow but suporting that seems |
| 7229 // overkill at this point. | 7457 // overkill at this point. |
| 7230 defineWrapGetter(Document, 'body'); | 7458 defineWrapGetter(Document, 'body'); |
| 7231 defineWrapGetter(Document, 'head'); | 7459 defineWrapGetter(Document, 'head'); |
| 7232 | 7460 |
| 7233 // document cannot be overridden so we override a bunch of its methods | 7461 // document cannot be overridden so we override a bunch of its methods |
| 7234 // directly on the instance. | 7462 // directly on the instance. |
| 7235 | 7463 |
| 7236 function wrapMethod(name) { | 7464 function wrapMethod(name) { |
| 7237 var original = document[name]; | 7465 var original = document[name]; |
| 7238 Document.prototype[name] = function() { | 7466 Document.prototype[name] = function() { |
| 7239 return wrap(original.apply(this.impl, arguments)); | 7467 return wrap(original.apply(unsafeUnwrap(this), arguments)); |
| 7240 }; | 7468 }; |
| 7241 } | 7469 } |
| 7242 | 7470 |
| 7243 [ | 7471 [ |
| 7244 'createComment', | 7472 'createComment', |
| 7245 'createDocumentFragment', | 7473 'createDocumentFragment', |
| 7246 'createElement', | 7474 'createElement', |
| 7247 'createElementNS', | 7475 'createElementNS', |
| 7248 'createEvent', | 7476 'createEvent', |
| 7249 'createEventNS', | 7477 'createEventNS', |
| 7250 'createRange', | 7478 'createRange', |
| 7251 'createTextNode', | 7479 'createTextNode', |
| 7252 'getElementById' | 7480 'getElementById' |
| 7253 ].forEach(wrapMethod); | 7481 ].forEach(wrapMethod); |
| 7254 | 7482 |
| 7255 var originalAdoptNode = document.adoptNode; | 7483 var originalAdoptNode = document.adoptNode; |
| 7256 | 7484 |
| 7257 function adoptNodeNoRemove(node, doc) { | 7485 function adoptNodeNoRemove(node, doc) { |
| 7258 originalAdoptNode.call(doc.impl, unwrap(node)); | 7486 originalAdoptNode.call(unsafeUnwrap(doc), unwrap(node)); |
| 7259 adoptSubtree(node, doc); | 7487 adoptSubtree(node, doc); |
| 7260 } | 7488 } |
| 7261 | 7489 |
| 7262 function adoptSubtree(node, doc) { | 7490 function adoptSubtree(node, doc) { |
| 7263 if (node.shadowRoot) | 7491 if (node.shadowRoot) |
| 7264 doc.adoptNode(node.shadowRoot); | 7492 doc.adoptNode(node.shadowRoot); |
| 7265 if (node instanceof ShadowRoot) | 7493 if (node instanceof ShadowRoot) |
| 7266 adoptOlderShadowRoots(node, doc); | 7494 adoptOlderShadowRoots(node, doc); |
| 7267 for (var child = node.firstChild; child; child = child.nextSibling) { | 7495 for (var child = node.firstChild; child; child = child.nextSibling) { |
| 7268 adoptSubtree(child, doc); | 7496 adoptSubtree(child, doc); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 7281 adoptNode: function(node) { | 7509 adoptNode: function(node) { |
| 7282 if (node.parentNode) | 7510 if (node.parentNode) |
| 7283 node.parentNode.removeChild(node); | 7511 node.parentNode.removeChild(node); |
| 7284 adoptNodeNoRemove(node, this); | 7512 adoptNodeNoRemove(node, this); |
| 7285 return node; | 7513 return node; |
| 7286 }, | 7514 }, |
| 7287 elementFromPoint: function(x, y) { | 7515 elementFromPoint: function(x, y) { |
| 7288 return elementFromPoint(this, this, x, y); | 7516 return elementFromPoint(this, this, x, y); |
| 7289 }, | 7517 }, |
| 7290 importNode: function(node, deep) { | 7518 importNode: function(node, deep) { |
| 7291 return cloneNode(node, deep, this.impl); | 7519 return cloneNode(node, deep, unsafeUnwrap(this)); |
| 7292 }, | 7520 }, |
| 7293 getSelection: function() { | 7521 getSelection: function() { |
| 7294 renderAllPending(); | 7522 renderAllPending(); |
| 7295 return new Selection(originalGetSelection.call(unwrap(this))); | 7523 return new Selection(originalGetSelection.call(unwrap(this))); |
| 7296 }, | 7524 }, |
| 7297 getElementsByName: function(name) { | 7525 getElementsByName: function(name) { |
| 7298 return SelectorsInterface.querySelectorAll.call(this, | 7526 return SelectorsInterface.querySelectorAll.call(this, |
| 7299 '[name=' + JSON.stringify(String(name)) + ']'); | 7527 '[name=' + JSON.stringify(String(name)) + ']'); |
| 7300 } | 7528 } |
| 7301 }); | 7529 }); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7376 p.extends = extendsOption; | 7604 p.extends = extendsOption; |
| 7377 | 7605 |
| 7378 function CustomElementConstructor(node) { | 7606 function CustomElementConstructor(node) { |
| 7379 if (!node) { | 7607 if (!node) { |
| 7380 if (extendsOption) { | 7608 if (extendsOption) { |
| 7381 return document.createElement(extendsOption, tagName); | 7609 return document.createElement(extendsOption, tagName); |
| 7382 } else { | 7610 } else { |
| 7383 return document.createElement(tagName); | 7611 return document.createElement(tagName); |
| 7384 } | 7612 } |
| 7385 } | 7613 } |
| 7386 this.impl = node; | 7614 setWrapper(node, this); |
| 7387 } | 7615 } |
| 7388 CustomElementConstructor.prototype = prototype; | 7616 CustomElementConstructor.prototype = prototype; |
| 7389 CustomElementConstructor.prototype.constructor = CustomElementConstructor; | 7617 CustomElementConstructor.prototype.constructor = CustomElementConstructor; |
| 7390 | 7618 |
| 7391 scope.constructorTable.set(newPrototype, CustomElementConstructor); | 7619 scope.constructorTable.set(newPrototype, CustomElementConstructor); |
| 7392 scope.nativePrototypeTable.set(prototype, newPrototype); | 7620 scope.nativePrototypeTable.set(prototype, newPrototype); |
| 7393 | 7621 |
| 7394 // registration is synchronous so do it last | 7622 // registration is synchronous so do it last |
| 7395 var nativeConstructor = originalRegisterElement.call(unwrap(this), | 7623 var nativeConstructor = originalRegisterElement.call(unwrap(this), |
| 7396 tagName, p); | 7624 tagName, p); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7473 if (window.HTMLDocument) | 7701 if (window.HTMLDocument) |
| 7474 registerWrapper(window.HTMLDocument, Document); | 7702 registerWrapper(window.HTMLDocument, Document); |
| 7475 | 7703 |
| 7476 wrapEventTargetMethods([ | 7704 wrapEventTargetMethods([ |
| 7477 window.HTMLBodyElement, | 7705 window.HTMLBodyElement, |
| 7478 window.HTMLDocument || window.Document, // Gecko adds these to HTMLDocument | 7706 window.HTMLDocument || window.Document, // Gecko adds these to HTMLDocument |
| 7479 window.HTMLHeadElement, | 7707 window.HTMLHeadElement, |
| 7480 ]); | 7708 ]); |
| 7481 | 7709 |
| 7482 function DOMImplementation(impl) { | 7710 function DOMImplementation(impl) { |
| 7483 this.impl = impl; | 7711 setWrapper(impl, this); |
| 7484 } | 7712 } |
| 7485 | 7713 |
| 7486 function wrapImplMethod(constructor, name) { | 7714 function wrapImplMethod(constructor, name) { |
| 7487 var original = document.implementation[name]; | 7715 var original = document.implementation[name]; |
| 7488 constructor.prototype[name] = function() { | 7716 constructor.prototype[name] = function() { |
| 7489 return wrap(original.apply(this.impl, arguments)); | 7717 return wrap(original.apply(unsafeUnwrap(this), arguments)); |
| 7490 }; | 7718 }; |
| 7491 } | 7719 } |
| 7492 | 7720 |
| 7493 function forwardImplMethod(constructor, name) { | 7721 function forwardImplMethod(constructor, name) { |
| 7494 var original = document.implementation[name]; | 7722 var original = document.implementation[name]; |
| 7495 constructor.prototype[name] = function() { | 7723 constructor.prototype[name] = function() { |
| 7496 return original.apply(this.impl, arguments); | 7724 return original.apply(unsafeUnwrap(this), arguments); |
| 7497 }; | 7725 }; |
| 7498 } | 7726 } |
| 7499 | 7727 |
| 7500 wrapImplMethod(DOMImplementation, 'createDocumentType'); | 7728 wrapImplMethod(DOMImplementation, 'createDocumentType'); |
| 7501 wrapImplMethod(DOMImplementation, 'createDocument'); | 7729 wrapImplMethod(DOMImplementation, 'createDocument'); |
| 7502 wrapImplMethod(DOMImplementation, 'createHTMLDocument'); | 7730 wrapImplMethod(DOMImplementation, 'createHTMLDocument'); |
| 7503 forwardImplMethod(DOMImplementation, 'hasFeature'); | 7731 forwardImplMethod(DOMImplementation, 'hasFeature'); |
| 7504 | 7732 |
| 7505 registerWrapper(window.DOMImplementation, DOMImplementation); | 7733 registerWrapper(window.DOMImplementation, DOMImplementation); |
| 7506 | 7734 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 7530 var Selection = scope.wrappers.Selection; | 7758 var Selection = scope.wrappers.Selection; |
| 7531 var mixin = scope.mixin; | 7759 var mixin = scope.mixin; |
| 7532 var registerWrapper = scope.registerWrapper; | 7760 var registerWrapper = scope.registerWrapper; |
| 7533 var renderAllPending = scope.renderAllPending; | 7761 var renderAllPending = scope.renderAllPending; |
| 7534 var unwrap = scope.unwrap; | 7762 var unwrap = scope.unwrap; |
| 7535 var unwrapIfNeeded = scope.unwrapIfNeeded; | 7763 var unwrapIfNeeded = scope.unwrapIfNeeded; |
| 7536 var wrap = scope.wrap; | 7764 var wrap = scope.wrap; |
| 7537 | 7765 |
| 7538 var OriginalWindow = window.Window; | 7766 var OriginalWindow = window.Window; |
| 7539 var originalGetComputedStyle = window.getComputedStyle; | 7767 var originalGetComputedStyle = window.getComputedStyle; |
| 7768 var originalGetDefaultComputedStyle = window.getDefaultComputedStyle; |
| 7540 var originalGetSelection = window.getSelection; | 7769 var originalGetSelection = window.getSelection; |
| 7541 | 7770 |
| 7542 function Window(impl) { | 7771 function Window(impl) { |
| 7543 EventTarget.call(this, impl); | 7772 EventTarget.call(this, impl); |
| 7544 } | 7773 } |
| 7545 Window.prototype = Object.create(EventTarget.prototype); | 7774 Window.prototype = Object.create(EventTarget.prototype); |
| 7546 | 7775 |
| 7547 OriginalWindow.prototype.getComputedStyle = function(el, pseudo) { | 7776 OriginalWindow.prototype.getComputedStyle = function(el, pseudo) { |
| 7548 return wrap(this || window).getComputedStyle(unwrapIfNeeded(el), pseudo); | 7777 return wrap(this || window).getComputedStyle(unwrapIfNeeded(el), pseudo); |
| 7549 }; | 7778 }; |
| 7550 | 7779 |
| 7780 // Mozilla proprietary extension. |
| 7781 if (originalGetDefaultComputedStyle) { |
| 7782 OriginalWindow.prototype.getDefaultComputedStyle = function(el, pseudo) { |
| 7783 return wrap(this || window).getDefaultComputedStyle( |
| 7784 unwrapIfNeeded(el), pseudo); |
| 7785 }; |
| 7786 } |
| 7787 |
| 7551 OriginalWindow.prototype.getSelection = function() { | 7788 OriginalWindow.prototype.getSelection = function() { |
| 7552 return wrap(this || window).getSelection(); | 7789 return wrap(this || window).getSelection(); |
| 7553 }; | 7790 }; |
| 7554 | 7791 |
| 7555 // Work around for https://bugzilla.mozilla.org/show_bug.cgi?id=943065 | 7792 // Work around for https://bugzilla.mozilla.org/show_bug.cgi?id=943065 |
| 7556 delete window.getComputedStyle; | 7793 delete window.getComputedStyle; |
| 7557 delete window.getSelection; | 7794 delete window.getSelection; |
| 7558 | 7795 |
| 7559 ['addEventListener', 'removeEventListener', 'dispatchEvent'].forEach( | 7796 ['addEventListener', 'removeEventListener', 'dispatchEvent'].forEach( |
| 7560 function(name) { | 7797 function(name) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 7576 getSelection: function() { | 7813 getSelection: function() { |
| 7577 renderAllPending(); | 7814 renderAllPending(); |
| 7578 return new Selection(originalGetSelection.call(unwrap(this))); | 7815 return new Selection(originalGetSelection.call(unwrap(this))); |
| 7579 }, | 7816 }, |
| 7580 | 7817 |
| 7581 get document() { | 7818 get document() { |
| 7582 return wrap(unwrap(this).document); | 7819 return wrap(unwrap(this).document); |
| 7583 } | 7820 } |
| 7584 }); | 7821 }); |
| 7585 | 7822 |
| 7823 // Mozilla proprietary extension. |
| 7824 if (originalGetDefaultComputedStyle) { |
| 7825 Window.prototype.getDefaultComputedStyle = function(el, pseudo) { |
| 7826 renderAllPending(); |
| 7827 return originalGetDefaultComputedStyle.call(unwrap(this), |
| 7828 unwrapIfNeeded(el),pseudo); |
| 7829 }; |
| 7830 } |
| 7831 |
| 7586 registerWrapper(OriginalWindow, Window, window); | 7832 registerWrapper(OriginalWindow, Window, window); |
| 7587 | 7833 |
| 7588 scope.wrappers.Window = Window; | 7834 scope.wrappers.Window = Window; |
| 7589 | 7835 |
| 7590 })(window.ShadowDOMPolyfill); | 7836 })(window.ShadowDOMPolyfill); |
| 7591 | 7837 |
| 7592 /** | 7838 /** |
| 7593 * Copyright 2014 The Polymer Authors. All rights reserved. | 7839 * Copyright 2014 The Polymer Authors. All rights reserved. |
| 7594 * Use of this source code is goverened by a BSD-style | 7840 * Use of this source code is goverened by a BSD-style |
| 7595 * license that can be found in the LICENSE file. | 7841 * license that can be found in the LICENSE file. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 7619 /** | 7865 /** |
| 7620 * Copyright 2014 The Polymer Authors. All rights reserved. | 7866 * Copyright 2014 The Polymer Authors. All rights reserved. |
| 7621 * Use of this source code is goverened by a BSD-style | 7867 * Use of this source code is goverened by a BSD-style |
| 7622 * license that can be found in the LICENSE file. | 7868 * license that can be found in the LICENSE file. |
| 7623 */ | 7869 */ |
| 7624 | 7870 |
| 7625 (function(scope) { | 7871 (function(scope) { |
| 7626 'use strict'; | 7872 'use strict'; |
| 7627 | 7873 |
| 7628 var registerWrapper = scope.registerWrapper; | 7874 var registerWrapper = scope.registerWrapper; |
| 7875 var setWrapper = scope.setWrapper; |
| 7629 var unwrap = scope.unwrap; | 7876 var unwrap = scope.unwrap; |
| 7630 | 7877 |
| 7631 var OriginalFormData = window.FormData; | 7878 var OriginalFormData = window.FormData; |
| 7632 | 7879 |
| 7633 function FormData(formElement) { | 7880 function FormData(formElement) { |
| 7634 this.impl = new OriginalFormData(formElement && unwrap(formElement)); | 7881 var impl; |
| 7882 if (formElement instanceof OriginalFormData) { |
| 7883 impl = formElement; |
| 7884 } else { |
| 7885 impl = new OriginalFormData(formElement && unwrap(formElement)); |
| 7886 } |
| 7887 setWrapper(impl, this); |
| 7635 } | 7888 } |
| 7636 | 7889 |
| 7637 registerWrapper(OriginalFormData, FormData, new OriginalFormData()); | 7890 registerWrapper(OriginalFormData, FormData, new OriginalFormData()); |
| 7638 | 7891 |
| 7639 scope.wrappers.FormData = FormData; | 7892 scope.wrappers.FormData = FormData; |
| 7640 | 7893 |
| 7641 })(window.ShadowDOMPolyfill); | 7894 })(window.ShadowDOMPolyfill); |
| 7642 | 7895 |
| 7643 // Copyright 2013 The Polymer Authors. All rights reserved. | 7896 // Copyright 2013 The Polymer Authors. All rights reserved. |
| 7644 // Use of this source code is goverened by a BSD-style | 7897 // Use of this source code is goverened by a BSD-style |
| (...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8388 } else { | 8641 } else { |
| 8389 addCssToDocument(cssText); | 8642 addCssToDocument(cssText); |
| 8390 } | 8643 } |
| 8391 } | 8644 } |
| 8392 }; | 8645 }; |
| 8393 | 8646 |
| 8394 var selectorRe = /([^{]*)({[\s\S]*?})/gim, | 8647 var selectorRe = /([^{]*)({[\s\S]*?})/gim, |
| 8395 cssCommentRe = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//gim, | 8648 cssCommentRe = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//gim, |
| 8396 // TODO(sorvell): remove either content or comment | 8649 // TODO(sorvell): remove either content or comment |
| 8397 cssCommentNextSelectorRe = /\/\*\s*@polyfill ([^*]*\*+([^/*][^*]*\*+)*\/)([^
{]*?){/gim, | 8650 cssCommentNextSelectorRe = /\/\*\s*@polyfill ([^*]*\*+([^/*][^*]*\*+)*\/)([^
{]*?){/gim, |
| 8398 cssContentNextSelectorRe = /polyfill-next-selector[^}]*content\:[\s]*['|"]([
^'"]*)['|"][^}]*}([^{]*?){/gim, | 8651 cssContentNextSelectorRe = /polyfill-next-selector[^}]*content\:[\s]*?['"](.
*?)['"][;\s]*}([^{]*?){/gim, |
| 8399 // TODO(sorvell): remove either content or comment | 8652 // TODO(sorvell): remove either content or comment |
| 8400 cssCommentRuleRe = /\/\*\s@polyfill-rule([^*]*\*+([^/*][^*]*\*+)*)\//gim, | 8653 cssCommentRuleRe = /\/\*\s@polyfill-rule([^*]*\*+([^/*][^*]*\*+)*)\//gim, |
| 8401 cssContentRuleRe = /(polyfill-rule)[^}]*(content\:[\s]*['|"]([^'"]*)['|"][^;
]*;)[^}]*}/gim, | 8654 cssContentRuleRe = /(polyfill-rule)[^}]*(content\:[\s]*['"](.*?)['"])[;\s]*[
^}]*}/gim, |
| 8402 // TODO(sorvell): remove either content or comment | 8655 // TODO(sorvell): remove either content or comment |
| 8403 cssCommentUnscopedRuleRe = /\/\*\s@polyfill-unscoped-rule([^*]*\*+([^/*][^*]
*\*+)*)\//gim, | 8656 cssCommentUnscopedRuleRe = /\/\*\s@polyfill-unscoped-rule([^*]*\*+([^/*][^*]
*\*+)*)\//gim, |
| 8404 cssContentUnscopedRuleRe = /(polyfill-unscoped-rule)[^}]*(content\:[\s]*['|"
]([^'"]*)['|"][^;]*;)[^}]*}/gim, | 8657 cssContentUnscopedRuleRe = /(polyfill-unscoped-rule)[^}]*(content\:[\s]*['"]
(.*?)['"])[;\s]*[^}]*}/gim, |
| 8405 cssPseudoRe = /::(x-[^\s{,(]*)/gim, | 8658 cssPseudoRe = /::(x-[^\s{,(]*)/gim, |
| 8406 cssPartRe = /::part\(([^)]*)\)/gim, | 8659 cssPartRe = /::part\(([^)]*)\)/gim, |
| 8407 // note: :host pre-processed to -shadowcsshost. | 8660 // note: :host pre-processed to -shadowcsshost. |
| 8408 polyfillHost = '-shadowcsshost', | 8661 polyfillHost = '-shadowcsshost', |
| 8409 // note: :host-context pre-processed to -shadowcsshostcontext. | 8662 // note: :host-context pre-processed to -shadowcsshostcontext. |
| 8410 polyfillHostContext = '-shadowcsscontext', | 8663 polyfillHostContext = '-shadowcsscontext', |
| 8411 parenSuffix = ')(?:\\((' + | 8664 parenSuffix = ')(?:\\((' + |
| 8412 '(?:\\([^)(]*\\)|[^)(]*)+?' + | 8665 '(?:\\([^)(]*\\)|[^)(]*)+?' + |
| 8413 ')\\))?([^,{]*)'; | 8666 ')\\))?([^,{]*)'; |
| 8414 cssColonHostRe = new RegExp('(' + polyfillHost + parenSuffix, 'gim'), | 8667 cssColonHostRe = new RegExp('(' + polyfillHost + parenSuffix, 'gim'), |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8590 style.textContent = ShadowCSS.shimStyle(style); | 8843 style.textContent = ShadowCSS.shimStyle(style); |
| 8591 style.removeAttribute(SHIM_ATTRIBUTE, ''); | 8844 style.removeAttribute(SHIM_ATTRIBUTE, ''); |
| 8592 style.setAttribute(SHIMMED_ATTRIBUTE, ''); | 8845 style.setAttribute(SHIMMED_ATTRIBUTE, ''); |
| 8593 style[SHIMMED_ATTRIBUTE] = true; | 8846 style[SHIMMED_ATTRIBUTE] = true; |
| 8594 // place in document | 8847 // place in document |
| 8595 if (style.parentNode !== head) { | 8848 if (style.parentNode !== head) { |
| 8596 // replace links in head | 8849 // replace links in head |
| 8597 if (elt.parentNode === head) { | 8850 if (elt.parentNode === head) { |
| 8598 head.replaceChild(style, elt); | 8851 head.replaceChild(style, elt); |
| 8599 } else { | 8852 } else { |
| 8600 head.appendChild(style); | 8853 this.addElementToDocument(style); |
| 8601 } | 8854 } |
| 8602 } | 8855 } |
| 8603 style.__importParsed = true; | 8856 style.__importParsed = true; |
| 8604 this.markParsingComplete(elt); | 8857 this.markParsingComplete(elt); |
| 8605 this.parseNext(); | 8858 this.parseNext(); |
| 8606 } | 8859 } |
| 8607 | 8860 |
| 8608 var hasResource = HTMLImports.parser.hasResource; | 8861 var hasResource = HTMLImports.parser.hasResource; |
| 8609 HTMLImports.parser.hasResource = function(node) { | 8862 HTMLImports.parser.hasResource = function(node) { |
| 8610 if (node.localName === 'link' && node.rel === 'stylesheet' && | 8863 if (node.localName === 'link' && node.rel === 'stylesheet' && |
| (...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9227 set hash(hash) { | 9480 set hash(hash) { |
| 9228 if (this._isInvalid) | 9481 if (this._isInvalid) |
| 9229 return; | 9482 return; |
| 9230 this._fragment = '#'; | 9483 this._fragment = '#'; |
| 9231 if ('#' == hash[0]) | 9484 if ('#' == hash[0]) |
| 9232 hash = hash.slice(1); | 9485 hash = hash.slice(1); |
| 9233 parse.call(this, hash, 'fragment'); | 9486 parse.call(this, hash, 'fragment'); |
| 9234 } | 9487 } |
| 9235 }; | 9488 }; |
| 9236 | 9489 |
| 9490 // Copy over the static methods |
| 9491 var OriginalURL = scope.URL; |
| 9492 if (OriginalURL) { |
| 9493 jURL.createObjectURL = function(blob) { |
| 9494 // IE extension allows a second optional options argument. |
| 9495 // http://msdn.microsoft.com/en-us/library/ie/hh772302(v=vs.85).aspx |
| 9496 return OriginalURL.createObjectURL.apply(OriginalURL, arguments); |
| 9497 }; |
| 9498 jURL.revokeObjectURL = function(url) { |
| 9499 OriginalURL.revokeObjectURL(url); |
| 9500 }; |
| 9501 } |
| 9502 |
| 9237 scope.URL = jURL; | 9503 scope.URL = jURL; |
| 9238 | 9504 |
| 9239 })(window); | 9505 })(this); |
| 9240 | 9506 |
| 9241 /* | 9507 /* |
| 9242 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. | 9508 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
| 9243 * This code may only be used under the BSD style license found at http://polyme
r.github.io/LICENSE.txt | 9509 * This code may only be used under the BSD style license found at http://polyme
r.github.io/LICENSE.txt |
| 9244 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.
txt | 9510 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.
txt |
| 9245 * The complete set of contributors may be found at http://polymer.github.io/CON
TRIBUTORS.txt | 9511 * The complete set of contributors may be found at http://polymer.github.io/CON
TRIBUTORS.txt |
| 9246 * Code distributed by Google as part of the polymer project is also | 9512 * Code distributed by Google as part of the polymer project is also |
| 9247 * subject to an additional IP rights grant found at http://polymer.github.io/PA
TENTS.txt | 9513 * subject to an additional IP rights grant found at http://polymer.github.io/PA
TENTS.txt |
| 9248 */ | 9514 */ |
| 9249 | 9515 |
| (...skipping 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10457 | 10723 |
| 10458 global.JsMutationObserver = JsMutationObserver; | 10724 global.JsMutationObserver = JsMutationObserver; |
| 10459 | 10725 |
| 10460 if (!global.MutationObserver) | 10726 if (!global.MutationObserver) |
| 10461 global.MutationObserver = JsMutationObserver; | 10727 global.MutationObserver = JsMutationObserver; |
| 10462 | 10728 |
| 10463 | 10729 |
| 10464 })(this); | 10730 })(this); |
| 10465 | 10731 |
| 10466 /* | 10732 /* |
| 10467 * Copyright 2013 The Polymer Authors. All rights reserved. | 10733 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
| 10468 * Use of this source code is governed by a BSD-style | 10734 * This code may only be used under the BSD style license found at http://polyme
r.github.io/LICENSE.txt |
| 10469 * license that can be found in the LICENSE file. | 10735 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.
txt |
| 10736 * The complete set of contributors may be found at http://polymer.github.io/CON
TRIBUTORS.txt |
| 10737 * Code distributed by Google as part of the polymer project is also |
| 10738 * subject to an additional IP rights grant found at http://polymer.github.io/PA
TENTS.txt |
| 10470 */ | 10739 */ |
| 10471 window.HTMLImports = window.HTMLImports || {flags:{}}; | 10740 window.HTMLImports = window.HTMLImports || {flags:{}}; |
| 10472 /* | 10741 /* |
| 10473 * Copyright 2013 The Polymer Authors. All rights reserved. | 10742 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
| 10474 * Use of this source code is governed by a BSD-style | 10743 * This code may only be used under the BSD style license found at http://polyme
r.github.io/LICENSE.txt |
| 10475 * license that can be found in the LICENSE file. | 10744 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.
txt |
| 10745 * The complete set of contributors may be found at http://polymer.github.io/CON
TRIBUTORS.txt |
| 10746 * Code distributed by Google as part of the polymer project is also |
| 10747 * subject to an additional IP rights grant found at http://polymer.github.io/PA
TENTS.txt |
| 10748 */(function(scope) { |
| 10749 |
| 10750 var hasNative = ('import' in document.createElement('link')); |
| 10751 var useNative = hasNative; |
| 10752 |
| 10753 isIE = /Trident/.test(navigator.userAgent); |
| 10754 |
| 10755 // TODO(sorvell): SD polyfill intrusion |
| 10756 var hasShadowDOMPolyfill = Boolean(window.ShadowDOMPolyfill); |
| 10757 var wrap = function(node) { |
| 10758 return hasShadowDOMPolyfill ? ShadowDOMPolyfill.wrapIfNeeded(node) : node; |
| 10759 }; |
| 10760 var mainDoc = wrap(document); |
| 10761 |
| 10762 // NOTE: We cannot polyfill document.currentScript because it's not possible |
| 10763 // both to override and maintain the ability to capture the native value; |
| 10764 // therefore we choose to expose _currentScript both when native imports |
| 10765 // and the polyfill are in use. |
| 10766 var currentScriptDescriptor = { |
| 10767 get: function() { |
| 10768 var script = HTMLImports.currentScript || document.currentScript || |
| 10769 // NOTE: only works when called in synchronously executing code. |
| 10770 // readyState should check if `loading` but IE10 is |
| 10771 // interactive when scripts run so we cheat. |
| 10772 (document.readyState !== 'complete' ? |
| 10773 document.scripts[document.scripts.length - 1] : null); |
| 10774 return wrap(script); |
| 10775 }, |
| 10776 configurable: true |
| 10777 }; |
| 10778 |
| 10779 Object.defineProperty(document, '_currentScript', currentScriptDescriptor); |
| 10780 Object.defineProperty(mainDoc, '_currentScript', currentScriptDescriptor); |
| 10781 |
| 10782 // call a callback when all HTMLImports in the document at call (or at least |
| 10783 // document ready) time have loaded. |
| 10784 // 1. ensure the document is in a ready state (has dom), then |
| 10785 // 2. watch for loading of imports and call callback when done |
| 10786 function whenImportsReady(callback, doc) { |
| 10787 doc = doc || mainDoc; |
| 10788 // if document is loading, wait and try again |
| 10789 whenDocumentReady(function() { |
| 10790 watchImportsLoad(callback, doc); |
| 10791 }, doc); |
| 10792 } |
| 10793 |
| 10794 // call the callback when the document is in a ready state (has dom) |
| 10795 var requiredReadyState = isIE ? 'complete' : 'interactive'; |
| 10796 var READY_EVENT = 'readystatechange'; |
| 10797 function isDocumentReady(doc) { |
| 10798 return (doc.readyState === 'complete' || |
| 10799 doc.readyState === requiredReadyState); |
| 10800 } |
| 10801 |
| 10802 // call <callback> when we ensure the document is in a ready state |
| 10803 function whenDocumentReady(callback, doc) { |
| 10804 if (!isDocumentReady(doc)) { |
| 10805 var checkReady = function() { |
| 10806 if (doc.readyState === 'complete' || |
| 10807 doc.readyState === requiredReadyState) { |
| 10808 doc.removeEventListener(READY_EVENT, checkReady); |
| 10809 whenDocumentReady(callback, doc); |
| 10810 } |
| 10811 } |
| 10812 doc.addEventListener(READY_EVENT, checkReady); |
| 10813 } else if (callback) { |
| 10814 callback(); |
| 10815 } |
| 10816 } |
| 10817 |
| 10818 // call <callback> when we ensure all imports have loaded |
| 10819 function watchImportsLoad(callback, doc) { |
| 10820 var imports = doc.querySelectorAll('link[rel=import]'); |
| 10821 var loaded = 0, l = imports.length; |
| 10822 function checkDone(d) { |
| 10823 if (loaded == l) { |
| 10824 callback && callback(); |
| 10825 } |
| 10826 } |
| 10827 function loadedImport(e) { |
| 10828 loaded++; |
| 10829 checkDone(); |
| 10830 } |
| 10831 if (l) { |
| 10832 for (var i=0, imp; (i<l) && (imp=imports[i]); i++) { |
| 10833 if (isImportLoaded(imp)) { |
| 10834 loadedImport.call(imp); |
| 10835 } else { |
| 10836 imp.addEventListener('load', loadedImport); |
| 10837 imp.addEventListener('error', loadedImport); |
| 10838 } |
| 10839 } |
| 10840 } else { |
| 10841 checkDone(); |
| 10842 } |
| 10843 } |
| 10844 |
| 10845 // NOTE: test for native imports loading is based on explicitly watching |
| 10846 // all imports (see below). |
| 10847 function isImportLoaded(link) { |
| 10848 return useNative ? link.__loaded : link.__importParsed; |
| 10849 } |
| 10850 |
| 10851 // TODO(sorvell): install a mutation observer to see if HTMLImports have loaded |
| 10852 // this is a workaround for https://www.w3.org/Bugs/Public/show_bug.cgi?id=25007 |
| 10853 // and should be removed when this bug is addressed. |
| 10854 if (useNative) { |
| 10855 new MutationObserver(function(mxns) { |
| 10856 for (var i=0, l=mxns.length, m; (i < l) && (m=mxns[i]); i++) { |
| 10857 if (m.addedNodes) { |
| 10858 handleImports(m.addedNodes); |
| 10859 } |
| 10860 } |
| 10861 }).observe(document.head, {childList: true}); |
| 10862 |
| 10863 function handleImports(nodes) { |
| 10864 for (var i=0, l=nodes.length, n; (i<l) && (n=nodes[i]); i++) { |
| 10865 if (isImport(n)) { |
| 10866 handleImport(n); |
| 10867 } |
| 10868 } |
| 10869 } |
| 10870 |
| 10871 function isImport(element) { |
| 10872 return element.localName === 'link' && element.rel === 'import'; |
| 10873 } |
| 10874 |
| 10875 function handleImport(element) { |
| 10876 var loaded = element.import; |
| 10877 if (loaded) { |
| 10878 markTargetLoaded({target: element}); |
| 10879 } else { |
| 10880 element.addEventListener('load', markTargetLoaded); |
| 10881 element.addEventListener('error', markTargetLoaded); |
| 10882 } |
| 10883 } |
| 10884 |
| 10885 function markTargetLoaded(event) { |
| 10886 event.target.__loaded = true; |
| 10887 } |
| 10888 |
| 10889 } |
| 10890 |
| 10891 // Fire the 'HTMLImportsLoaded' event when imports in document at load time |
| 10892 // have loaded. This event is required to simulate the script blocking |
| 10893 // behavior of native imports. A main document script that needs to be sure |
| 10894 // imports have loaded should wait for this event. |
| 10895 whenImportsReady(function() { |
| 10896 HTMLImports.ready = true; |
| 10897 HTMLImports.readyTime = new Date().getTime(); |
| 10898 mainDoc.dispatchEvent( |
| 10899 new CustomEvent('HTMLImportsLoaded', {bubbles: true}) |
| 10900 ); |
| 10901 }); |
| 10902 |
| 10903 // exports |
| 10904 scope.useNative = useNative; |
| 10905 scope.isImportLoaded = isImportLoaded; |
| 10906 scope.whenReady = whenImportsReady; |
| 10907 scope.isIE = isIE; |
| 10908 |
| 10909 // deprecated |
| 10910 scope.whenImportsReady = whenImportsReady; |
| 10911 |
| 10912 })(window.HTMLImports); |
| 10913 |
| 10914 /* |
| 10915 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
| 10916 * This code may only be used under the BSD style license found at http://polyme
r.github.io/LICENSE.txt |
| 10917 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.
txt |
| 10918 * The complete set of contributors may be found at http://polymer.github.io/CON
TRIBUTORS.txt |
| 10919 * Code distributed by Google as part of the polymer project is also |
| 10920 * subject to an additional IP rights grant found at http://polymer.github.io/PA
TENTS.txt |
| 10476 */ | 10921 */ |
| 10477 | |
| 10478 (function(scope) { | 10922 (function(scope) { |
| 10479 | 10923 |
| 10480 // imports | 10924 // imports |
| 10481 var path = scope.path; | 10925 var path = scope.path; |
| 10482 var xhr = scope.xhr; | 10926 var xhr = scope.xhr; |
| 10483 var flags = scope.flags; | 10927 var flags = scope.flags; |
| 10484 | 10928 |
| 10485 // TODO(sorvell): this loader supports a dynamic list of urls | 10929 // TODO(sorvell): this loader supports a dynamic list of urls |
| 10486 // and an oncomplete callback that is called when the loader is done. | 10930 // and an oncomplete callback that is called when the loader is done. |
| 10487 // The polyfill currently does *not* need this dynamism or the onComplete | 10931 // The polyfill currently does *not* need this dynamism or the onComplete |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10576 xhr.loadDocument(url, receiveXhr); | 11020 xhr.loadDocument(url, receiveXhr); |
| 10577 } else { | 11021 } else { |
| 10578 xhr.load(url, receiveXhr); | 11022 xhr.load(url, receiveXhr); |
| 10579 } | 11023 } |
| 10580 */ | 11024 */ |
| 10581 } | 11025 } |
| 10582 }, | 11026 }, |
| 10583 receive: function(url, elt, err, resource, redirectedUrl) { | 11027 receive: function(url, elt, err, resource, redirectedUrl) { |
| 10584 this.cache[url] = resource; | 11028 this.cache[url] = resource; |
| 10585 var $p = this.pending[url]; | 11029 var $p = this.pending[url]; |
| 10586 if ( redirectedUrl && redirectedUrl !== url ) { | |
| 10587 this.cache[redirectedUrl] = resource; | |
| 10588 $p = $p.concat(this.pending[redirectedUrl]); | |
| 10589 } | |
| 10590 for (var i=0, l=$p.length, p; (i<l) && (p=$p[i]); i++) { | 11030 for (var i=0, l=$p.length, p; (i<l) && (p=$p[i]); i++) { |
| 10591 //if (!err) { | 11031 // If url was redirected, use the redirected location so paths are |
| 10592 // If url was redirected, use the redirected location so paths are | 11032 // calculated relative to that. |
| 10593 // calculated relative to that. | 11033 this.onload(url, p, resource, err, redirectedUrl); |
| 10594 this.onload(redirectedUrl || url, p, resource); | |
| 10595 //} | |
| 10596 this.tail(); | 11034 this.tail(); |
| 10597 } | 11035 } |
| 10598 this.pending[url] = null; | 11036 this.pending[url] = null; |
| 10599 if ( redirectedUrl && redirectedUrl !== url ) { | |
| 10600 this.pending[redirectedUrl] = null; | |
| 10601 } | |
| 10602 }, | 11037 }, |
| 10603 tail: function() { | 11038 tail: function() { |
| 10604 --this.inflight; | 11039 --this.inflight; |
| 10605 this.checkDone(); | 11040 this.checkDone(); |
| 10606 }, | 11041 }, |
| 10607 checkDone: function() { | 11042 checkDone: function() { |
| 10608 if (!this.inflight) { | 11043 if (!this.inflight) { |
| 10609 this.oncomplete(); | 11044 this.oncomplete(); |
| 10610 } | 11045 } |
| 10611 } | 11046 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 10626 request.open('GET', url, xhr.async); | 11061 request.open('GET', url, xhr.async); |
| 10627 request.addEventListener('readystatechange', function(e) { | 11062 request.addEventListener('readystatechange', function(e) { |
| 10628 if (request.readyState === 4) { | 11063 if (request.readyState === 4) { |
| 10629 // Servers redirecting an import can add a Location header to help us | 11064 // Servers redirecting an import can add a Location header to help us |
| 10630 // polyfill correctly. | 11065 // polyfill correctly. |
| 10631 var locationHeader = request.getResponseHeader("Location"); | 11066 var locationHeader = request.getResponseHeader("Location"); |
| 10632 var redirectedUrl = null; | 11067 var redirectedUrl = null; |
| 10633 if (locationHeader) { | 11068 if (locationHeader) { |
| 10634 var redirectedUrl = (locationHeader.substr( 0, 1 ) === "/") | 11069 var redirectedUrl = (locationHeader.substr( 0, 1 ) === "/") |
| 10635 ? location.origin + locationHeader // Location is a relative path | 11070 ? location.origin + locationHeader // Location is a relative path |
| 10636 : redirectedUrl; // Full path | 11071 : locationHeader; // Full path |
| 10637 } | 11072 } |
| 10638 next.call(nextContext, !xhr.ok(request) && request, | 11073 next.call(nextContext, !xhr.ok(request) && request, |
| 10639 request.response || request.responseText, redirectedUrl); | 11074 request.response || request.responseText, redirectedUrl); |
| 10640 } | 11075 } |
| 10641 }); | 11076 }); |
| 10642 request.send(); | 11077 request.send(); |
| 10643 return request; | 11078 return request; |
| 10644 }, | 11079 }, |
| 10645 loadDocument: function(url, next, nextContext) { | 11080 loadDocument: function(url, next, nextContext) { |
| 10646 this.load(url, next, nextContext).responseType = 'document'; | 11081 this.load(url, next, nextContext).responseType = 'document'; |
| 10647 } | 11082 } |
| 10648 }; | 11083 }; |
| 10649 | 11084 |
| 10650 // exports | 11085 // exports |
| 10651 scope.xhr = xhr; | 11086 scope.xhr = xhr; |
| 10652 scope.Loader = Loader; | 11087 scope.Loader = Loader; |
| 10653 | 11088 |
| 10654 })(window.HTMLImports); | 11089 })(window.HTMLImports); |
| 10655 | 11090 |
| 10656 /* | 11091 /* |
| 10657 * Copyright 2013 The Polymer Authors. All rights reserved. | 11092 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
| 10658 * Use of this source code is governed by a BSD-style | 11093 * This code may only be used under the BSD style license found at http://polyme
r.github.io/LICENSE.txt |
| 10659 * license that can be found in the LICENSE file. | 11094 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.
txt |
| 11095 * The complete set of contributors may be found at http://polymer.github.io/CON
TRIBUTORS.txt |
| 11096 * Code distributed by Google as part of the polymer project is also |
| 11097 * subject to an additional IP rights grant found at http://polymer.github.io/PA
TENTS.txt |
| 10660 */ | 11098 */ |
| 10661 | |
| 10662 (function(scope) { | 11099 (function(scope) { |
| 10663 | 11100 |
| 10664 var IMPORT_LINK_TYPE = 'import'; | 11101 var IMPORT_LINK_TYPE = 'import'; |
| 10665 var flags = scope.flags; | 11102 var flags = scope.flags; |
| 10666 var isIe = /Trident/.test(navigator.userAgent); | 11103 var isIE = scope.isIE; |
| 10667 // TODO(sorvell): SD polyfill intrusion | 11104 // TODO(sorvell): SD polyfill intrusion |
| 10668 var mainDoc = window.ShadowDOMPolyfill ? | 11105 var mainDoc = window.ShadowDOMPolyfill ? |
| 10669 window.ShadowDOMPolyfill.wrapIfNeeded(document) : document; | 11106 window.ShadowDOMPolyfill.wrapIfNeeded(document) : document; |
| 10670 | 11107 |
| 10671 // importParser | 11108 // importParser |
| 10672 // highlander object to manage parsing of imports | 11109 // highlander object to manage parsing of imports |
| 10673 // parses import related elements | 11110 // parses import related elements |
| 10674 // and ensures proper parse order | 11111 // and ensures proper parse order |
| 10675 // parse order is enforced by crawling the tree and monitoring which elements | 11112 // parse order is enforced by crawling the tree and monitoring which elements |
| 10676 // have been parsed; async parsing is also supported. | 11113 // have been parsed; async parsing is also supported. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10745 parser.parseNext(); | 11182 parser.parseNext(); |
| 10746 }); | 11183 }); |
| 10747 }, | 11184 }, |
| 10748 parseImport: function(elt) { | 11185 parseImport: function(elt) { |
| 10749 // TODO(sorvell): consider if there's a better way to do this; | 11186 // TODO(sorvell): consider if there's a better way to do this; |
| 10750 // expose an imports parsing hook; this is needed, for example, by the | 11187 // expose an imports parsing hook; this is needed, for example, by the |
| 10751 // CustomElements polyfill. | 11188 // CustomElements polyfill. |
| 10752 if (HTMLImports.__importsParsingHook) { | 11189 if (HTMLImports.__importsParsingHook) { |
| 10753 HTMLImports.__importsParsingHook(elt); | 11190 HTMLImports.__importsParsingHook(elt); |
| 10754 } | 11191 } |
| 10755 elt.import.__importParsed = true; | 11192 if (elt.import) { |
| 11193 elt.import.__importParsed = true; |
| 11194 } |
| 10756 this.markParsingComplete(elt); | 11195 this.markParsingComplete(elt); |
| 10757 // fire load event | 11196 // fire load event |
| 10758 if (elt.__resource) { | 11197 if (elt.__resource && !elt.__error) { |
| 10759 elt.dispatchEvent(new CustomEvent('load', {bubbles: false})); | 11198 elt.dispatchEvent(new CustomEvent('load', {bubbles: false})); |
| 10760 } else { | 11199 } else { |
| 10761 elt.dispatchEvent(new CustomEvent('error', {bubbles: false})); | 11200 elt.dispatchEvent(new CustomEvent('error', {bubbles: false})); |
| 10762 } | 11201 } |
| 10763 // TODO(sorvell): workaround for Safari addEventListener not working | 11202 // TODO(sorvell): workaround for Safari addEventListener not working |
| 10764 // for elements not in the main document. | 11203 // for elements not in the main document. |
| 10765 if (elt.__pending) { | 11204 if (elt.__pending) { |
| 10766 var fn; | 11205 var fn; |
| 10767 while (elt.__pending.length) { | 11206 while (elt.__pending.length) { |
| 10768 fn = elt.__pending.shift(); | 11207 fn = elt.__pending.shift(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 10784 }, | 11223 }, |
| 10785 parseStyle: function(elt) { | 11224 parseStyle: function(elt) { |
| 10786 // TODO(sorvell): style element load event can just not fire so clone styles | 11225 // TODO(sorvell): style element load event can just not fire so clone styles |
| 10787 var src = elt; | 11226 var src = elt; |
| 10788 elt = cloneStyle(elt); | 11227 elt = cloneStyle(elt); |
| 10789 elt.__importElement = src; | 11228 elt.__importElement = src; |
| 10790 this.parseGeneric(elt); | 11229 this.parseGeneric(elt); |
| 10791 }, | 11230 }, |
| 10792 parseGeneric: function(elt) { | 11231 parseGeneric: function(elt) { |
| 10793 this.trackElement(elt); | 11232 this.trackElement(elt); |
| 10794 document.head.appendChild(elt); | 11233 this.addElementToDocument(elt); |
| 11234 }, |
| 11235 rootImportForElement: function(elt) { |
| 11236 var n = elt; |
| 11237 while (n.ownerDocument.__importLink) { |
| 11238 n = n.ownerDocument.__importLink; |
| 11239 } |
| 11240 return n; |
| 11241 }, |
| 11242 addElementToDocument: function(elt) { |
| 11243 var port = this.rootImportForElement(elt.__importElement || elt); |
| 11244 var l = port.__insertedElements = port.__insertedElements || 0; |
| 11245 var refNode = port.nextElementSibling; |
| 11246 for (var i=0; i < l; i++) { |
| 11247 refNode = refNode && refNode.nextElementSibling; |
| 11248 } |
| 11249 port.parentNode.insertBefore(elt, refNode); |
| 10795 }, | 11250 }, |
| 10796 // tracks when a loadable element has loaded | 11251 // tracks when a loadable element has loaded |
| 10797 trackElement: function(elt, callback) { | 11252 trackElement: function(elt, callback) { |
| 10798 var self = this; | 11253 var self = this; |
| 10799 var done = function(e) { | 11254 var done = function(e) { |
| 10800 if (callback) { | 11255 if (callback) { |
| 10801 callback(e); | 11256 callback(e); |
| 10802 } | 11257 } |
| 10803 self.markParsingComplete(elt); | 11258 self.markParsingComplete(elt); |
| 10804 self.parseNext(); | 11259 self.parseNext(); |
| 10805 }; | 11260 }; |
| 10806 elt.addEventListener('load', done); | 11261 elt.addEventListener('load', done); |
| 10807 elt.addEventListener('error', done); | 11262 elt.addEventListener('error', done); |
| 10808 | 11263 |
| 10809 // NOTE: IE does not fire "load" event for styles that have already loaded | 11264 // NOTE: IE does not fire "load" event for styles that have already loaded |
| 10810 // This is in violation of the spec, so we try our hardest to work around it | 11265 // This is in violation of the spec, so we try our hardest to work around it |
| 10811 if (isIe && elt.localName === 'style') { | 11266 if (isIE && elt.localName === 'style') { |
| 10812 var fakeLoad = false; | 11267 var fakeLoad = false; |
| 10813 // If there's not @import in the textContent, assume it has loaded | 11268 // If there's not @import in the textContent, assume it has loaded |
| 10814 if (elt.textContent.indexOf('@import') == -1) { | 11269 if (elt.textContent.indexOf('@import') == -1) { |
| 10815 fakeLoad = true; | 11270 fakeLoad = true; |
| 10816 // if we have a sheet, we have been parsed | 11271 // if we have a sheet, we have been parsed |
| 10817 } else if (elt.sheet) { | 11272 } else if (elt.sheet) { |
| 10818 fakeLoad = true; | 11273 fakeLoad = true; |
| 10819 var csr = elt.sheet.cssRules; | 11274 var csr = elt.sheet.cssRules; |
| 10820 var len = csr ? csr.length : 0; | 11275 var len = csr ? csr.length : 0; |
| 10821 // search the rules for @import's | 11276 // search the rules for @import's |
| (...skipping 19 matching lines...) Expand all Loading... |
| 10841 parseScript: function(scriptElt) { | 11296 parseScript: function(scriptElt) { |
| 10842 var script = document.createElement('script'); | 11297 var script = document.createElement('script'); |
| 10843 script.__importElement = scriptElt; | 11298 script.__importElement = scriptElt; |
| 10844 script.src = scriptElt.src ? scriptElt.src : | 11299 script.src = scriptElt.src ? scriptElt.src : |
| 10845 generateScriptDataUrl(scriptElt); | 11300 generateScriptDataUrl(scriptElt); |
| 10846 scope.currentScript = scriptElt; | 11301 scope.currentScript = scriptElt; |
| 10847 this.trackElement(script, function(e) { | 11302 this.trackElement(script, function(e) { |
| 10848 script.parentNode.removeChild(script); | 11303 script.parentNode.removeChild(script); |
| 10849 scope.currentScript = null; | 11304 scope.currentScript = null; |
| 10850 }); | 11305 }); |
| 10851 document.head.appendChild(script); | 11306 this.addElementToDocument(script); |
| 10852 }, | 11307 }, |
| 10853 // determine the next element in the tree which should be parsed | 11308 // determine the next element in the tree which should be parsed |
| 10854 nextToParse: function() { | 11309 nextToParse: function() { |
| 10855 return !this.parsingElement && this.nextToParseInDoc(mainDoc); | 11310 return !this.parsingElement && this.nextToParseInDoc(mainDoc); |
| 10856 }, | 11311 }, |
| 10857 nextToParseInDoc: function(doc, link) { | 11312 nextToParseInDoc: function(doc, link) { |
| 10858 var nodes = doc.querySelectorAll(this.parseSelectorsForNode(doc)); | 11313 if (doc) { |
| 10859 for (var i=0, l=nodes.length, p=0, n; (i<l) && (n=nodes[i]); i++) { | 11314 var nodes = doc.querySelectorAll(this.parseSelectorsForNode(doc)); |
| 10860 if (!this.isParsed(n)) { | 11315 for (var i=0, l=nodes.length, p=0, n; (i<l) && (n=nodes[i]); i++) { |
| 10861 if (this.hasResource(n)) { | 11316 if (!this.isParsed(n)) { |
| 10862 return nodeIsImport(n) ? this.nextToParseInDoc(n.import, n) : n; | 11317 if (this.hasResource(n)) { |
| 10863 } else { | 11318 return nodeIsImport(n) ? this.nextToParseInDoc(n.import, n) : n; |
| 10864 return; | 11319 } else { |
| 11320 return; |
| 11321 } |
| 10865 } | 11322 } |
| 10866 } | 11323 } |
| 10867 } | 11324 } |
| 10868 // all nodes have been parsed, ready to parse import, if any | 11325 // all nodes have been parsed, ready to parse import, if any |
| 10869 return link; | 11326 return link; |
| 10870 }, | 11327 }, |
| 10871 // return the set of parse selectors relevant for this node. | 11328 // return the set of parse selectors relevant for this node. |
| 10872 parseSelectorsForNode: function(node) { | 11329 parseSelectorsForNode: function(node) { |
| 10873 var doc = node.ownerDocument || node; | 11330 var doc = node.ownerDocument || node; |
| 10874 return doc === mainDoc ? this.documentSelectors : this.importsSelectors; | 11331 return doc === mainDoc ? this.documentSelectors : this.importsSelectors; |
| 10875 }, | 11332 }, |
| 10876 isParsed: function(node) { | 11333 isParsed: function(node) { |
| 10877 return node.__importParsed; | 11334 return node.__importParsed; |
| 10878 }, | 11335 }, |
| 10879 hasResource: function(node) { | 11336 hasResource: function(node) { |
| 10880 if (nodeIsImport(node) && !node.import) { | 11337 if (nodeIsImport(node) && (node.import === undefined)) { |
| 10881 return false; | 11338 return false; |
| 10882 } | 11339 } |
| 10883 return true; | 11340 return true; |
| 10884 } | 11341 } |
| 10885 }; | 11342 }; |
| 10886 | 11343 |
| 10887 function nodeIsImport(elt) { | 11344 function nodeIsImport(elt) { |
| 10888 return (elt.localName === 'link') && (elt.rel === IMPORT_LINK_TYPE); | 11345 return (elt.localName === 'link') && (elt.rel === IMPORT_LINK_TYPE); |
| 10889 } | 11346 } |
| 10890 | 11347 |
| 10891 function generateScriptDataUrl(script) { | 11348 function generateScriptDataUrl(script) { |
| 10892 var scriptContent = generateScriptContent(script); | 11349 var scriptContent = generateScriptContent(script); |
| 10893 var b64 = 'data:text/javascript'; | 11350 return 'data:text/javascript;charset=utf-8,' + encodeURIComponent(scriptConten
t); |
| 10894 // base64 may be smaller, but does not handle unicode characters | |
| 10895 // attempt base64 first, fall back to escaped text | |
| 10896 try { | |
| 10897 b64 += (';base64,' + btoa(scriptContent)); | |
| 10898 } catch(e) { | |
| 10899 b64 += (';charset=utf-8,' + encodeURIComponent(scriptContent)); | |
| 10900 } | |
| 10901 return b64; | |
| 10902 } | 11351 } |
| 10903 | 11352 |
| 10904 function generateScriptContent(script) { | 11353 function generateScriptContent(script) { |
| 10905 return script.textContent + generateSourceMapHint(script); | 11354 return script.textContent + generateSourceMapHint(script); |
| 10906 } | 11355 } |
| 10907 | 11356 |
| 10908 // calculate source map hint | 11357 // calculate source map hint |
| 10909 function generateSourceMapHint(script) { | 11358 function generateSourceMapHint(script) { |
| 10910 var moniker = script.__nodeUrl; | 11359 var moniker = script.__nodeUrl; |
| 10911 if (!moniker) { | 11360 if (!moniker) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10956 urlObj.href = urlPath; | 11405 urlObj.href = urlPath; |
| 10957 urlPath = urlObj.href; | 11406 urlPath = urlObj.href; |
| 10958 return pre + '\'' + urlPath + '\'' + post; | 11407 return pre + '\'' + urlPath + '\'' + post; |
| 10959 }); | 11408 }); |
| 10960 } | 11409 } |
| 10961 } | 11410 } |
| 10962 | 11411 |
| 10963 // exports | 11412 // exports |
| 10964 scope.parser = importParser; | 11413 scope.parser = importParser; |
| 10965 scope.path = path; | 11414 scope.path = path; |
| 10966 scope.isIE = isIe; | |
| 10967 | 11415 |
| 10968 })(HTMLImports); | 11416 })(HTMLImports); |
| 10969 | 11417 |
| 10970 /* | 11418 /* |
| 10971 * Copyright 2013 The Polymer Authors. All rights reserved. | 11419 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
| 10972 * Use of this source code is governed by a BSD-style | 11420 * This code may only be used under the BSD style license found at http://polyme
r.github.io/LICENSE.txt |
| 10973 * license that can be found in the LICENSE file. | 11421 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.
txt |
| 11422 * The complete set of contributors may be found at http://polymer.github.io/CON
TRIBUTORS.txt |
| 11423 * Code distributed by Google as part of the polymer project is also |
| 11424 * subject to an additional IP rights grant found at http://polymer.github.io/PA
TENTS.txt |
| 10974 */ | 11425 */ |
| 11426 (function(scope) { |
| 10975 | 11427 |
| 10976 (function(scope) { | 11428 var useNative = scope.useNative; |
| 10977 | |
| 10978 var hasNative = ('import' in document.createElement('link')); | |
| 10979 var useNative = hasNative; | |
| 10980 var flags = scope.flags; | 11429 var flags = scope.flags; |
| 10981 var IMPORT_LINK_TYPE = 'import'; | 11430 var IMPORT_LINK_TYPE = 'import'; |
| 10982 | 11431 |
| 10983 // TODO(sorvell): SD polyfill intrusion | 11432 // TODO(sorvell): SD polyfill intrusion |
| 10984 var mainDoc = window.ShadowDOMPolyfill ? | 11433 var mainDoc = window.ShadowDOMPolyfill ? |
| 10985 ShadowDOMPolyfill.wrapIfNeeded(document) : document; | 11434 ShadowDOMPolyfill.wrapIfNeeded(document) : document; |
| 10986 | 11435 |
| 10987 if (!useNative) { | 11436 if (!useNative) { |
| 10988 | 11437 |
| 10989 // imports | 11438 // imports |
| (...skipping 27 matching lines...) Expand all Loading... |
| 11017 marshalNodes: function(parent) { | 11466 marshalNodes: function(parent) { |
| 11018 // all preloadable nodes in inDocument | 11467 // all preloadable nodes in inDocument |
| 11019 return parent.querySelectorAll(this.loadSelectorsForNode(parent)); | 11468 return parent.querySelectorAll(this.loadSelectorsForNode(parent)); |
| 11020 }, | 11469 }, |
| 11021 // find the proper set of load selectors for a given node | 11470 // find the proper set of load selectors for a given node |
| 11022 loadSelectorsForNode: function(node) { | 11471 loadSelectorsForNode: function(node) { |
| 11023 var doc = node.ownerDocument || node; | 11472 var doc = node.ownerDocument || node; |
| 11024 return doc === mainDoc ? this.documentPreloadSelectors : | 11473 return doc === mainDoc ? this.documentPreloadSelectors : |
| 11025 this.importsPreloadSelectors; | 11474 this.importsPreloadSelectors; |
| 11026 }, | 11475 }, |
| 11027 loaded: function(url, elt, resource) { | 11476 loaded: function(url, elt, resource, err, redirectedUrl) { |
| 11028 flags.load && console.log('loaded', url, elt); | 11477 flags.load && console.log('loaded', url, elt); |
| 11029 // store generic resource | 11478 // store generic resource |
| 11030 // TODO(sorvell): fails for nodes inside <template>.content | 11479 // TODO(sorvell): fails for nodes inside <template>.content |
| 11031 // see https://code.google.com/p/chromium/issues/detail?id=249381. | 11480 // see https://code.google.com/p/chromium/issues/detail?id=249381. |
| 11032 elt.__resource = resource; | 11481 elt.__resource = resource; |
| 11482 elt.__error = err; |
| 11033 if (isDocumentLink(elt)) { | 11483 if (isDocumentLink(elt)) { |
| 11034 var doc = this.documents[url]; | 11484 var doc = this.documents[url]; |
| 11035 // if we've never seen a document at this url | 11485 // if we've never seen a document at this url |
| 11036 if (!doc) { | 11486 if (doc === undefined) { |
| 11037 // generate an HTMLDocument from data | 11487 // generate an HTMLDocument from data |
| 11038 doc = makeDocument(resource, url); | 11488 doc = err ? null : makeDocument(resource, redirectedUrl || url); |
| 11039 doc.__importLink = elt; | 11489 if (doc) { |
| 11040 // TODO(sorvell): we cannot use MO to detect parsed nodes because | 11490 doc.__importLink = elt; |
| 11041 // SD polyfill does not report these as mutations. | 11491 // note, we cannot use MO to detect parsed nodes because |
| 11042 this.bootDocument(doc); | 11492 // SD polyfill does not report these as mutations. |
| 11493 this.bootDocument(doc); |
| 11494 } |
| 11043 // cache document | 11495 // cache document |
| 11044 this.documents[url] = doc; | 11496 this.documents[url] = doc; |
| 11045 } | 11497 } |
| 11046 // don't store import record until we're actually loaded | 11498 // don't store import record until we're actually loaded |
| 11047 // store document resource | 11499 // store document resource |
| 11048 elt.import = doc; | 11500 elt.import = doc; |
| 11049 } | 11501 } |
| 11050 parser.parseNext(); | 11502 parser.parseNext(); |
| 11051 }, | 11503 }, |
| 11052 bootDocument: function(doc) { | 11504 bootDocument: function(doc) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11105 // install html | 11557 // install html |
| 11106 doc.body.innerHTML = resource; | 11558 doc.body.innerHTML = resource; |
| 11107 } | 11559 } |
| 11108 // TODO(sorvell): ideally this code is not aware of Template polyfill, | 11560 // TODO(sorvell): ideally this code is not aware of Template polyfill, |
| 11109 // but for now the polyfill needs help to bootstrap these templates | 11561 // but for now the polyfill needs help to bootstrap these templates |
| 11110 if (window.HTMLTemplateElement && HTMLTemplateElement.bootstrap) { | 11562 if (window.HTMLTemplateElement && HTMLTemplateElement.bootstrap) { |
| 11111 HTMLTemplateElement.bootstrap(doc); | 11563 HTMLTemplateElement.bootstrap(doc); |
| 11112 } | 11564 } |
| 11113 return doc; | 11565 return doc; |
| 11114 } | 11566 } |
| 11567 |
| 11568 // Polyfill document.baseURI for browsers without it. |
| 11569 if (!document.baseURI) { |
| 11570 var baseURIDescriptor = { |
| 11571 get: function() { |
| 11572 var base = document.querySelector('base'); |
| 11573 return base ? base.href : window.location.href; |
| 11574 }, |
| 11575 configurable: true |
| 11576 }; |
| 11577 |
| 11578 Object.defineProperty(document, 'baseURI', baseURIDescriptor); |
| 11579 Object.defineProperty(mainDoc, 'baseURI', baseURIDescriptor); |
| 11580 } |
| 11581 |
| 11582 // IE shim for CustomEvent |
| 11583 if (typeof window.CustomEvent !== 'function') { |
| 11584 window.CustomEvent = function(inType, dictionary) { |
| 11585 var e = document.createEvent('HTMLEvents'); |
| 11586 e.initEvent(inType, |
| 11587 dictionary.bubbles === false ? false : true, |
| 11588 dictionary.cancelable === false ? false : true, |
| 11589 dictionary.detail); |
| 11590 return e; |
| 11591 }; |
| 11592 } |
| 11593 |
| 11115 } else { | 11594 } else { |
| 11116 // do nothing if using native imports | 11595 // do nothing if using native imports |
| 11117 var importer = {}; | 11596 var importer = {}; |
| 11118 } | 11597 } |
| 11119 | 11598 |
| 11120 // NOTE: We cannot polyfill document.currentScript because it's not possible | |
| 11121 // both to override and maintain the ability to capture the native value; | |
| 11122 // therefore we choose to expose _currentScript both when native imports | |
| 11123 // and the polyfill are in use. | |
| 11124 var currentScriptDescriptor = { | |
| 11125 get: function() { | |
| 11126 return HTMLImports.currentScript || document.currentScript; | |
| 11127 }, | |
| 11128 configurable: true | |
| 11129 }; | |
| 11130 | |
| 11131 Object.defineProperty(document, '_currentScript', currentScriptDescriptor); | |
| 11132 Object.defineProperty(mainDoc, '_currentScript', currentScriptDescriptor); | |
| 11133 | |
| 11134 // Polyfill document.baseURI for browsers without it. | |
| 11135 if (!document.baseURI) { | |
| 11136 var baseURIDescriptor = { | |
| 11137 get: function() { | |
| 11138 return window.location.href; | |
| 11139 }, | |
| 11140 configurable: true | |
| 11141 }; | |
| 11142 | |
| 11143 Object.defineProperty(document, 'baseURI', baseURIDescriptor); | |
| 11144 Object.defineProperty(mainDoc, 'baseURI', baseURIDescriptor); | |
| 11145 } | |
| 11146 | |
| 11147 // call a callback when all HTMLImports in the document at call (or at least | |
| 11148 // document ready) time have loaded. | |
| 11149 // 1. ensure the document is in a ready state (has dom), then | |
| 11150 // 2. watch for loading of imports and call callback when done | |
| 11151 function whenImportsReady(callback, doc) { | |
| 11152 doc = doc || mainDoc; | |
| 11153 // if document is loading, wait and try again | |
| 11154 whenDocumentReady(function() { | |
| 11155 watchImportsLoad(callback, doc); | |
| 11156 }, doc); | |
| 11157 } | |
| 11158 | |
| 11159 // call the callback when the document is in a ready state (has dom) | |
| 11160 var requiredReadyState = HTMLImports.isIE ? 'complete' : 'interactive'; | |
| 11161 var READY_EVENT = 'readystatechange'; | |
| 11162 function isDocumentReady(doc) { | |
| 11163 return (doc.readyState === 'complete' || | |
| 11164 doc.readyState === requiredReadyState); | |
| 11165 } | |
| 11166 | |
| 11167 // call <callback> when we ensure the document is in a ready state | |
| 11168 function whenDocumentReady(callback, doc) { | |
| 11169 if (!isDocumentReady(doc)) { | |
| 11170 var checkReady = function() { | |
| 11171 if (doc.readyState === 'complete' || | |
| 11172 doc.readyState === requiredReadyState) { | |
| 11173 doc.removeEventListener(READY_EVENT, checkReady); | |
| 11174 whenDocumentReady(callback, doc); | |
| 11175 } | |
| 11176 } | |
| 11177 doc.addEventListener(READY_EVENT, checkReady); | |
| 11178 } else if (callback) { | |
| 11179 callback(); | |
| 11180 } | |
| 11181 } | |
| 11182 | |
| 11183 // call <callback> when we ensure all imports have loaded | |
| 11184 function watchImportsLoad(callback, doc) { | |
| 11185 var imports = doc.querySelectorAll('link[rel=import]'); | |
| 11186 var loaded = 0, l = imports.length; | |
| 11187 function checkDone(d) { | |
| 11188 if (loaded == l) { | |
| 11189 callback && callback(); | |
| 11190 } | |
| 11191 } | |
| 11192 function loadedImport(e) { | |
| 11193 loaded++; | |
| 11194 checkDone(); | |
| 11195 } | |
| 11196 if (l) { | |
| 11197 for (var i=0, imp; (i<l) && (imp=imports[i]); i++) { | |
| 11198 if (isImportLoaded(imp)) { | |
| 11199 loadedImport.call(imp); | |
| 11200 } else { | |
| 11201 imp.addEventListener('load', loadedImport); | |
| 11202 imp.addEventListener('error', loadedImport); | |
| 11203 } | |
| 11204 } | |
| 11205 } else { | |
| 11206 checkDone(); | |
| 11207 } | |
| 11208 } | |
| 11209 | |
| 11210 function isImportLoaded(link) { | |
| 11211 return useNative ? (link.import && (link.import.readyState !== 'loading')) ||
link.__loaded : | |
| 11212 link.__importParsed; | |
| 11213 } | |
| 11214 | |
| 11215 // TODO(sorvell): install a mutation observer to see if HTMLImports have loaded | |
| 11216 // this is a workaround for https://www.w3.org/Bugs/Public/show_bug.cgi?id=25007 | |
| 11217 // and should be removed when this bug is addressed. | |
| 11218 if (useNative) { | |
| 11219 new MutationObserver(function(mxns) { | |
| 11220 for (var i=0, l=mxns.length, m; (i < l) && (m=mxns[i]); i++) { | |
| 11221 if (m.addedNodes) { | |
| 11222 handleImports(m.addedNodes); | |
| 11223 } | |
| 11224 } | |
| 11225 }).observe(document.head, {childList: true}); | |
| 11226 | |
| 11227 function handleImports(nodes) { | |
| 11228 for (var i=0, l=nodes.length, n; (i<l) && (n=nodes[i]); i++) { | |
| 11229 if (isImport(n)) { | |
| 11230 handleImport(n); | |
| 11231 } | |
| 11232 } | |
| 11233 } | |
| 11234 | |
| 11235 function isImport(element) { | |
| 11236 return element.localName === 'link' && element.rel === 'import'; | |
| 11237 } | |
| 11238 | |
| 11239 function handleImport(element) { | |
| 11240 var loaded = element.import; | |
| 11241 if (loaded) { | |
| 11242 markTargetLoaded({target: element}); | |
| 11243 } else { | |
| 11244 element.addEventListener('load', markTargetLoaded); | |
| 11245 element.addEventListener('error', markTargetLoaded); | |
| 11246 } | |
| 11247 } | |
| 11248 | |
| 11249 function markTargetLoaded(event) { | |
| 11250 event.target.__loaded = true; | |
| 11251 } | |
| 11252 | |
| 11253 } | |
| 11254 | |
| 11255 // exports | 11599 // exports |
| 11256 scope.hasNative = hasNative; | |
| 11257 scope.useNative = useNative; | |
| 11258 scope.importer = importer; | 11600 scope.importer = importer; |
| 11259 scope.IMPORT_LINK_TYPE = IMPORT_LINK_TYPE; | 11601 scope.IMPORT_LINK_TYPE = IMPORT_LINK_TYPE; |
| 11260 scope.isImportLoaded = isImportLoaded; | |
| 11261 scope.importLoader = importLoader; | 11602 scope.importLoader = importLoader; |
| 11262 scope.whenReady = whenImportsReady; | |
| 11263 | 11603 |
| 11264 // deprecated | |
| 11265 scope.whenImportsReady = whenImportsReady; | |
| 11266 | 11604 |
| 11267 })(window.HTMLImports); | 11605 })(window.HTMLImports); |
| 11268 | 11606 |
| 11269 /* | 11607 /* |
| 11270 Copyright 2013 The Polymer Authors. All rights reserved. | 11608 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
| 11271 Use of this source code is governed by a BSD-style | 11609 * This code may only be used under the BSD style license found at http://polyme
r.github.io/LICENSE.txt |
| 11272 license that can be found in the LICENSE file. | 11610 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.
txt |
| 11273 */ | 11611 * The complete set of contributors may be found at http://polymer.github.io/CON
TRIBUTORS.txt |
| 11274 | 11612 * Code distributed by Google as part of the polymer project is also |
| 11613 * subject to an additional IP rights grant found at http://polymer.github.io/PA
TENTS.txt |
| 11614 */ |
| 11275 (function(scope){ | 11615 (function(scope){ |
| 11276 | 11616 |
| 11277 var IMPORT_LINK_TYPE = scope.IMPORT_LINK_TYPE; | 11617 var IMPORT_LINK_TYPE = scope.IMPORT_LINK_TYPE; |
| 11278 var importSelector = 'link[rel=' + IMPORT_LINK_TYPE + ']'; | 11618 var importSelector = 'link[rel=' + IMPORT_LINK_TYPE + ']'; |
| 11279 var importer = scope.importer; | 11619 var importer = scope.importer; |
| 11280 var parser = scope.parser; | 11620 var parser = scope.parser; |
| 11281 | 11621 |
| 11282 // we track mutations for addedNodes, looking for imports | 11622 // we track mutations for addedNodes, looking for imports |
| 11283 function handler(mutations) { | 11623 function handler(mutations) { |
| 11284 for (var i=0, l=mutations.length, m; (i<l) && (m=mutations[i]); i++) { | 11624 for (var i=0, l=mutations.length, m; (i<l) && (m=mutations[i]); i++) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11330 } | 11670 } |
| 11331 | 11671 |
| 11332 // exports | 11672 // exports |
| 11333 // TODO(sorvell): factor so can put on scope | 11673 // TODO(sorvell): factor so can put on scope |
| 11334 scope.observe = observe; | 11674 scope.observe = observe; |
| 11335 importer.observe = observe; | 11675 importer.observe = observe; |
| 11336 | 11676 |
| 11337 })(HTMLImports); | 11677 })(HTMLImports); |
| 11338 | 11678 |
| 11339 /* | 11679 /* |
| 11340 * Copyright 2013 The Polymer Authors. All rights reserved. | 11680 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
| 11341 * Use of this source code is governed by a BSD-style | 11681 * This code may only be used under the BSD style license found at http://polyme
r.github.io/LICENSE.txt |
| 11342 * license that can be found in the LICENSE file. | 11682 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.
txt |
| 11683 * The complete set of contributors may be found at http://polymer.github.io/CON
TRIBUTORS.txt |
| 11684 * Code distributed by Google as part of the polymer project is also |
| 11685 * subject to an additional IP rights grant found at http://polymer.github.io/PA
TENTS.txt |
| 11343 */ | 11686 */ |
| 11344 (function(){ | 11687 (function(){ |
| 11345 | 11688 |
| 11346 // bootstrap | 11689 // bootstrap |
| 11347 | 11690 |
| 11348 // IE shim for CustomEvent | |
| 11349 if (typeof window.CustomEvent !== 'function') { | |
| 11350 window.CustomEvent = function(inType, dictionary) { | |
| 11351 var e = document.createEvent('HTMLEvents'); | |
| 11352 e.initEvent(inType, | |
| 11353 dictionary.bubbles === false ? false : true, | |
| 11354 dictionary.cancelable === false ? false : true, | |
| 11355 dictionary.detail); | |
| 11356 return e; | |
| 11357 }; | |
| 11358 } | |
| 11359 | |
| 11360 // TODO(sorvell): SD polyfill intrusion | 11691 // TODO(sorvell): SD polyfill intrusion |
| 11361 var doc = window.ShadowDOMPolyfill ? | 11692 var doc = window.ShadowDOMPolyfill ? |
| 11362 window.ShadowDOMPolyfill.wrapIfNeeded(document) : document; | 11693 window.ShadowDOMPolyfill.wrapIfNeeded(document) : document; |
| 11363 | 11694 |
| 11364 // Fire the 'HTMLImportsLoaded' event when imports in document at load time | |
| 11365 // have loaded. This event is required to simulate the script blocking | |
| 11366 // behavior of native imports. A main document script that needs to be sure | |
| 11367 // imports have loaded should wait for this event. | |
| 11368 HTMLImports.whenImportsReady(function() { | |
| 11369 HTMLImports.ready = true; | |
| 11370 HTMLImports.readyTime = new Date().getTime(); | |
| 11371 doc.dispatchEvent( | |
| 11372 new CustomEvent('HTMLImportsLoaded', {bubbles: true}) | |
| 11373 ); | |
| 11374 }); | |
| 11375 | |
| 11376 | |
| 11377 // no need to bootstrap the polyfill when native imports is available. | 11695 // no need to bootstrap the polyfill when native imports is available. |
| 11378 if (!HTMLImports.useNative) { | 11696 if (!HTMLImports.useNative) { |
| 11379 function bootstrap() { | 11697 function bootstrap() { |
| 11380 HTMLImports.importer.bootDocument(doc); | 11698 HTMLImports.importer.bootDocument(doc); |
| 11381 } | 11699 } |
| 11382 | 11700 |
| 11383 // TODO(sorvell): SD polyfill does *not* generate mutations for nodes added | 11701 // TODO(sorvell): SD polyfill does *not* generate mutations for nodes added |
| 11384 // by the parser. For this reason, we must wait until the dom exists to | 11702 // by the parser. For this reason, we must wait until the dom exists to |
| 11385 // bootstrap. | 11703 // bootstrap. |
| 11386 if (document.readyState === 'complete' || | 11704 if (document.readyState === 'complete' || |
| 11387 (document.readyState === 'interactive' && !window.attachEvent)) { | 11705 (document.readyState === 'interactive' && !window.attachEvent)) { |
| 11388 bootstrap(); | 11706 bootstrap(); |
| 11389 } else { | 11707 } else { |
| 11390 document.addEventListener('DOMContentLoaded', bootstrap); | 11708 document.addEventListener('DOMContentLoaded', bootstrap); |
| 11391 } | 11709 } |
| 11392 } | 11710 } |
| 11393 | 11711 |
| 11394 })(); | 11712 })(); |
| 11395 | 11713 |
| 11396 /* | 11714 /* |
| 11397 * Copyright 2013 The Polymer Authors. All rights reserved. | 11715 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
| 11398 * Use of this source code is governed by a BSD-style | 11716 * This code may only be used under the BSD style license found at http://polyme
r.github.io/LICENSE.txt |
| 11399 * license that can be found in the LICENSE file. | 11717 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.
txt |
| 11718 * The complete set of contributors may be found at http://polymer.github.io/CON
TRIBUTORS.txt |
| 11719 * Code distributed by Google as part of the polymer project is also |
| 11720 * subject to an additional IP rights grant found at http://polymer.github.io/PA
TENTS.txt |
| 11400 */ | 11721 */ |
| 11401 window.CustomElements = window.CustomElements || {flags:{}}; | 11722 window.CustomElements = window.CustomElements || {flags:{}}; |
| 11402 /* | 11723 /* |
| 11403 Copyright 2013 The Polymer Authors. All rights reserved. | 11724 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
| 11404 Use of this source code is governed by a BSD-style | 11725 * This code may only be used under the BSD style license found at http://polyme
r.github.io/LICENSE.txt |
| 11405 license that can be found in the LICENSE file. | 11726 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.
txt |
| 11406 */ | 11727 * The complete set of contributors may be found at http://polymer.github.io/CON
TRIBUTORS.txt |
| 11728 * Code distributed by Google as part of the polymer project is also |
| 11729 * subject to an additional IP rights grant found at http://polymer.github.io/PA
TENTS.txt |
| 11730 */ |
| 11407 | 11731 |
| 11408 (function(scope){ | 11732 (function(scope){ |
| 11409 | 11733 |
| 11410 var logFlags = window.logFlags || {}; | 11734 var logFlags = window.logFlags || {}; |
| 11411 var IMPORT_LINK_TYPE = window.HTMLImports ? HTMLImports.IMPORT_LINK_TYPE : 'none
'; | 11735 var IMPORT_LINK_TYPE = window.HTMLImports ? HTMLImports.IMPORT_LINK_TYPE : 'none
'; |
| 11412 | 11736 |
| 11413 // walk the subtree rooted at node, applying 'find(element, data)' function | 11737 // walk the subtree rooted at node, applying 'find(element, data)' function |
| 11414 // to each element | 11738 // to each element |
| 11415 // if 'find' returns true for 'element', do not search element's subtree | 11739 // if 'find' returns true for 'element', do not search element's subtree |
| 11416 function findAll(node, find, data) { | 11740 function findAll(node, find, data) { |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11738 scope.insertedNode = insertedNode; | 12062 scope.insertedNode = insertedNode; |
| 11739 | 12063 |
| 11740 scope.observeDocument = observeDocument; | 12064 scope.observeDocument = observeDocument; |
| 11741 scope.upgradeDocument = upgradeDocument; | 12065 scope.upgradeDocument = upgradeDocument; |
| 11742 | 12066 |
| 11743 scope.takeRecords = takeRecords; | 12067 scope.takeRecords = takeRecords; |
| 11744 | 12068 |
| 11745 })(window.CustomElements); | 12069 })(window.CustomElements); |
| 11746 | 12070 |
| 11747 /* | 12071 /* |
| 11748 * Copyright 2013 The Polymer Authors. All rights reserved. | 12072 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
| 11749 * Use of this source code is governed by a BSD-style | 12073 * This code may only be used under the BSD style license found at http://polyme
r.github.io/LICENSE.txt |
| 11750 * license that can be found in the LICENSE file. | 12074 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.
txt |
| 12075 * The complete set of contributors may be found at http://polymer.github.io/CON
TRIBUTORS.txt |
| 12076 * Code distributed by Google as part of the polymer project is also |
| 12077 * subject to an additional IP rights grant found at http://polymer.github.io/PA
TENTS.txt |
| 11751 */ | 12078 */ |
| 11752 | 12079 |
| 11753 /** | 12080 /** |
| 11754 * Implements `document.register` | 12081 * Implements `document.registerElement` |
| 11755 * @module CustomElements | 12082 * @module CustomElements |
| 11756 */ | 12083 */ |
| 11757 | 12084 |
| 11758 /** | 12085 /** |
| 11759 * Polyfilled extensions to the `document` object. | 12086 * Polyfilled extensions to the `document` object. |
| 11760 * @class Document | 12087 * @class Document |
| 11761 */ | 12088 */ |
| 11762 | 12089 |
| 11763 (function(scope) { | 12090 (function(scope) { |
| 11764 | 12091 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11976 // output is a valid DOM element with the proper wrapper in place. | 12303 // output is a valid DOM element with the proper wrapper in place. |
| 11977 // | 12304 // |
| 11978 return upgrade(domCreateElement(definition.tag), definition); | 12305 return upgrade(domCreateElement(definition.tag), definition); |
| 11979 } | 12306 } |
| 11980 | 12307 |
| 11981 function upgrade(element, definition) { | 12308 function upgrade(element, definition) { |
| 11982 // some definitions specify an 'is' attribute | 12309 // some definitions specify an 'is' attribute |
| 11983 if (definition.is) { | 12310 if (definition.is) { |
| 11984 element.setAttribute('is', definition.is); | 12311 element.setAttribute('is', definition.is); |
| 11985 } | 12312 } |
| 11986 // remove 'unresolved' attr, which is a standin for :unresolved. | |
| 11987 element.removeAttribute('unresolved'); | |
| 11988 // make 'element' implement definition.prototype | 12313 // make 'element' implement definition.prototype |
| 11989 implement(element, definition); | 12314 implement(element, definition); |
| 11990 // flag as upgraded | 12315 // flag as upgraded |
| 11991 element.__upgraded__ = true; | 12316 element.__upgraded__ = true; |
| 11992 // lifecycle management | 12317 // lifecycle management |
| 11993 created(element); | 12318 created(element); |
| 11994 // attachedCallback fires in tree order, call before recursing | 12319 // attachedCallback fires in tree order, call before recursing |
| 11995 scope.insertedNode(element); | 12320 scope.insertedNode(element); |
| 11996 // there should never be a shadow root on element at this point | 12321 // there should never be a shadow root on element at this point |
| 11997 scope.upgradeSubtree(element); | 12322 scope.upgradeSubtree(element); |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12215 | 12540 |
| 12216 // bc | 12541 // bc |
| 12217 document.register = document.registerElement; | 12542 document.register = document.registerElement; |
| 12218 | 12543 |
| 12219 scope.hasNative = hasNative; | 12544 scope.hasNative = hasNative; |
| 12220 scope.useNative = useNative; | 12545 scope.useNative = useNative; |
| 12221 | 12546 |
| 12222 })(window.CustomElements); | 12547 })(window.CustomElements); |
| 12223 | 12548 |
| 12224 /* | 12549 /* |
| 12225 * Copyright 2013 The Polymer Authors. All rights reserved. | 12550 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
| 12226 * Use of this source code is governed by a BSD-style | 12551 * This code may only be used under the BSD style license found at http://polyme
r.github.io/LICENSE.txt |
| 12227 * license that can be found in the LICENSE file. | 12552 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.
txt |
| 12553 * The complete set of contributors may be found at http://polymer.github.io/CON
TRIBUTORS.txt |
| 12554 * Code distributed by Google as part of the polymer project is also |
| 12555 * subject to an additional IP rights grant found at http://polymer.github.io/PA
TENTS.txt |
| 12228 */ | 12556 */ |
| 12229 | 12557 |
| 12230 (function(scope) { | 12558 (function(scope) { |
| 12231 | 12559 |
| 12232 // import | 12560 // import |
| 12233 | 12561 |
| 12234 var IMPORT_LINK_TYPE = scope.IMPORT_LINK_TYPE; | 12562 var IMPORT_LINK_TYPE = scope.IMPORT_LINK_TYPE; |
| 12235 | 12563 |
| 12236 // highlander object for parsing a document tree | 12564 // highlander object for parsing a document tree |
| 12237 | 12565 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12279 | 12607 |
| 12280 var forEach = Array.prototype.forEach.call.bind(Array.prototype.forEach); | 12608 var forEach = Array.prototype.forEach.call.bind(Array.prototype.forEach); |
| 12281 | 12609 |
| 12282 // exports | 12610 // exports |
| 12283 | 12611 |
| 12284 scope.parser = parser; | 12612 scope.parser = parser; |
| 12285 scope.IMPORT_LINK_TYPE = IMPORT_LINK_TYPE; | 12613 scope.IMPORT_LINK_TYPE = IMPORT_LINK_TYPE; |
| 12286 | 12614 |
| 12287 })(window.CustomElements); | 12615 })(window.CustomElements); |
| 12288 /* | 12616 /* |
| 12289 * Copyright 2013 The Polymer Authors. All rights reserved. | 12617 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
| 12290 * Use of this source code is governed by a BSD-style | 12618 * This code may only be used under the BSD style license found at http://polyme
r.github.io/LICENSE.txt |
| 12291 * license that can be found in the LICENSE file. | 12619 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.
txt |
| 12620 * The complete set of contributors may be found at http://polymer.github.io/CON
TRIBUTORS.txt |
| 12621 * Code distributed by Google as part of the polymer project is also |
| 12622 * subject to an additional IP rights grant found at http://polymer.github.io/PA
TENTS.txt |
| 12292 */ | 12623 */ |
| 12293 (function(scope){ | 12624 (function(scope){ |
| 12294 | 12625 |
| 12295 // bootstrap parsing | 12626 // bootstrap parsing |
| 12296 function bootstrap() { | 12627 function bootstrap() { |
| 12297 // parse document | 12628 // parse document |
| 12298 CustomElements.parser.parse(document); | 12629 CustomElements.parser.parse(document); |
| 12299 // one more pass before register is 'live' | 12630 // one more pass before register is 'live' |
| 12300 CustomElements.upgradeDocument(document); | 12631 CustomElements.upgradeDocument(document); |
| 12301 // choose async | 12632 // install upgrade hook if HTMLImports are available |
| 12302 var async = window.Platform && Platform.endOfMicrotask ? | 12633 if (window.HTMLImports) { |
| 12303 Platform.endOfMicrotask : | 12634 HTMLImports.__importsParsingHook = function(elt) { |
| 12304 setTimeout; | 12635 CustomElements.parser.parse(elt.import); |
| 12305 async(function() { | 12636 } |
| 12306 // set internal 'ready' flag, now document.registerElement will trigger | 12637 } |
| 12307 // synchronous upgrades | 12638 // set internal 'ready' flag, now document.registerElement will trigger |
| 12308 CustomElements.ready = true; | 12639 // synchronous upgrades |
| 12640 CustomElements.ready = true; |
| 12641 // async to ensure *native* custom elements upgrade prior to this |
| 12642 // DOMContentLoaded can fire before elements upgrade (e.g. when there's |
| 12643 // an external script) |
| 12644 setTimeout(function() { |
| 12309 // capture blunt profiling data | 12645 // capture blunt profiling data |
| 12310 CustomElements.readyTime = Date.now(); | 12646 CustomElements.readyTime = Date.now(); |
| 12311 if (window.HTMLImports) { | 12647 if (window.HTMLImports) { |
| 12312 CustomElements.elapsed = CustomElements.readyTime - HTMLImports.readyTime; | 12648 CustomElements.elapsed = CustomElements.readyTime - HTMLImports.readyTime; |
| 12313 } | 12649 } |
| 12314 // notify the system that we are bootstrapped | 12650 // notify the system that we are bootstrapped |
| 12315 document.dispatchEvent( | 12651 document.dispatchEvent( |
| 12316 new CustomEvent('WebComponentsReady', {bubbles: true}) | 12652 new CustomEvent('WebComponentsReady', {bubbles: true}) |
| 12317 ); | 12653 ); |
| 12318 | |
| 12319 // install upgrade hook if HTMLImports are available | |
| 12320 if (window.HTMLImports) { | |
| 12321 HTMLImports.__importsParsingHook = function(elt) { | |
| 12322 CustomElements.parser.parse(elt.import); | |
| 12323 } | |
| 12324 } | |
| 12325 }); | 12654 }); |
| 12326 } | 12655 } |
| 12327 | 12656 |
| 12328 // CustomEvent shim for IE | 12657 // CustomEvent shim for IE |
| 12329 if (typeof window.CustomEvent !== 'function') { | 12658 if (typeof window.CustomEvent !== 'function') { |
| 12330 window.CustomEvent = function(inType) { | 12659 window.CustomEvent = function(inType, params) { |
| 12331 var e = document.createEvent('HTMLEvents'); | 12660 params = params || {}; |
| 12332 e.initEvent(inType, true, true); | 12661 var e = document.createEvent('CustomEvent'); |
| 12662 e.initCustomEvent(inType, Boolean(params.bubbles), Boolean(params.cancelable
), params.detail); |
| 12333 return e; | 12663 return e; |
| 12334 }; | 12664 }; |
| 12665 window.CustomEvent.prototype = window.Event.prototype; |
| 12335 } | 12666 } |
| 12336 | 12667 |
| 12337 // When loading at readyState complete time (or via flag), boot custom elements | 12668 // When loading at readyState complete time (or via flag), boot custom elements |
| 12338 // immediately. | 12669 // immediately. |
| 12339 // If relevant, HTMLImports must already be loaded. | 12670 // If relevant, HTMLImports must already be loaded. |
| 12340 if (document.readyState === 'complete' || scope.flags.eager) { | 12671 if (document.readyState === 'complete' || scope.flags.eager) { |
| 12341 bootstrap(); | 12672 bootstrap(); |
| 12342 // When loading at readyState interactive time, bootstrap only if HTMLImports | 12673 // When loading at readyState interactive time, bootstrap only if HTMLImports |
| 12343 // are not pending. Also avoid IE as the semantics of this state are unreliable. | 12674 // are not pending. Also avoid IE as the semantics of this state are unreliable. |
| 12344 } else if (document.readyState === 'interactive' && !window.attachEvent && | 12675 } else if (document.readyState === 'interactive' && !window.attachEvent && |
| (...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13489 get bindingDelegate() { | 13820 get bindingDelegate() { |
| 13490 return this.delegate_ && this.delegate_.raw; | 13821 return this.delegate_ && this.delegate_.raw; |
| 13491 }, | 13822 }, |
| 13492 | 13823 |
| 13493 refChanged_: function() { | 13824 refChanged_: function() { |
| 13494 if (!this.iterator_ || this.refContent_ === this.ref_.content) | 13825 if (!this.iterator_ || this.refContent_ === this.ref_.content) |
| 13495 return; | 13826 return; |
| 13496 | 13827 |
| 13497 this.refContent_ = undefined; | 13828 this.refContent_ = undefined; |
| 13498 this.iterator_.valueChanged(); | 13829 this.iterator_.valueChanged(); |
| 13499 this.iterator_.updateIteratedValue(); | 13830 this.iterator_.updateIteratedValue(this.iterator_.getUpdatedValue()); |
| 13500 }, | 13831 }, |
| 13501 | 13832 |
| 13502 clear: function() { | 13833 clear: function() { |
| 13503 this.model_ = undefined; | 13834 this.model_ = undefined; |
| 13504 this.delegate_ = undefined; | 13835 this.delegate_ = undefined; |
| 13505 if (this.bindings_ && this.bindings_.ref) | 13836 if (this.bindings_ && this.bindings_.ref) |
| 13506 this.bindings_.ref.close() | 13837 this.bindings_.ref.close() |
| 13507 this.refContent_ = undefined; | 13838 this.refContent_ = undefined; |
| 13508 if (!this.iterator_) | 13839 if (!this.iterator_) |
| 13509 return; | 13840 return; |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13893 deps.value.close(); | 14224 deps.value.close(); |
| 13894 } | 14225 } |
| 13895 }, | 14226 }, |
| 13896 | 14227 |
| 13897 updateDependencies: function(directives, model) { | 14228 updateDependencies: function(directives, model) { |
| 13898 this.closeDeps(); | 14229 this.closeDeps(); |
| 13899 | 14230 |
| 13900 var deps = this.deps = {}; | 14231 var deps = this.deps = {}; |
| 13901 var template = this.templateElement_; | 14232 var template = this.templateElement_; |
| 13902 | 14233 |
| 14234 var ifValue = true; |
| 13903 if (directives.if) { | 14235 if (directives.if) { |
| 13904 deps.hasIf = true; | 14236 deps.hasIf = true; |
| 13905 deps.ifOneTime = directives.if.onlyOneTime; | 14237 deps.ifOneTime = directives.if.onlyOneTime; |
| 13906 deps.ifValue = processBinding(IF, directives.if, template, model); | 14238 deps.ifValue = processBinding(IF, directives.if, template, model); |
| 13907 | 14239 |
| 14240 ifValue = deps.ifValue; |
| 14241 |
| 13908 // oneTime if & predicate is false. nothing else to do. | 14242 // oneTime if & predicate is false. nothing else to do. |
| 13909 if (deps.ifOneTime && !deps.ifValue) { | 14243 if (deps.ifOneTime && !ifValue) { |
| 13910 this.updateIteratedValue(); | 14244 this.valueChanged(); |
| 13911 return; | 14245 return; |
| 13912 } | 14246 } |
| 13913 | 14247 |
| 13914 if (!deps.ifOneTime) | 14248 if (!deps.ifOneTime) |
| 13915 deps.ifValue.open(this.updateIteratedValue, this); | 14249 ifValue = ifValue.open(this.updateIfValue, this); |
| 13916 } | 14250 } |
| 13917 | 14251 |
| 13918 if (directives.repeat) { | 14252 if (directives.repeat) { |
| 13919 deps.repeat = true; | 14253 deps.repeat = true; |
| 13920 deps.oneTime = directives.repeat.onlyOneTime; | 14254 deps.oneTime = directives.repeat.onlyOneTime; |
| 13921 deps.value = processBinding(REPEAT, directives.repeat, template, model); | 14255 deps.value = processBinding(REPEAT, directives.repeat, template, model); |
| 13922 } else { | 14256 } else { |
| 13923 deps.repeat = false; | 14257 deps.repeat = false; |
| 13924 deps.oneTime = directives.bind.onlyOneTime; | 14258 deps.oneTime = directives.bind.onlyOneTime; |
| 13925 deps.value = processBinding(BIND, directives.bind, template, model); | 14259 deps.value = processBinding(BIND, directives.bind, template, model); |
| 13926 } | 14260 } |
| 13927 | 14261 |
| 14262 var value = deps.value; |
| 13928 if (!deps.oneTime) | 14263 if (!deps.oneTime) |
| 13929 deps.value.open(this.updateIteratedValue, this); | 14264 value = value.open(this.updateIteratedValue, this); |
| 13930 | 14265 |
| 13931 this.updateIteratedValue(); | 14266 if (!ifValue) { |
| 14267 this.valueChanged(); |
| 14268 return; |
| 14269 } |
| 14270 |
| 14271 this.updateValue(value); |
| 13932 }, | 14272 }, |
| 13933 | 14273 |
| 13934 updateIteratedValue: function() { | 14274 /** |
| 14275 * Gets the updated value of the bind/repeat. This can potentially call |
| 14276 * user code (if a bindingDelegate is set up) so we try to avoid it if we |
| 14277 * already have the value in hand (from Observer.open). |
| 14278 */ |
| 14279 getUpdatedValue: function() { |
| 14280 var value = this.deps.value; |
| 14281 if (!this.deps.oneTime) |
| 14282 value = value.discardChanges(); |
| 14283 return value; |
| 14284 }, |
| 14285 |
| 14286 updateIfValue: function(ifValue) { |
| 14287 if (!ifValue) { |
| 14288 this.valueChanged(); |
| 14289 return; |
| 14290 } |
| 14291 |
| 14292 this.updateValue(this.getUpdatedValue()); |
| 14293 }, |
| 14294 |
| 14295 updateIteratedValue: function(value) { |
| 13935 if (this.deps.hasIf) { | 14296 if (this.deps.hasIf) { |
| 13936 var ifValue = this.deps.ifValue; | 14297 var ifValue = this.deps.ifValue; |
| 13937 if (!this.deps.ifOneTime) | 14298 if (!this.deps.ifOneTime) |
| 13938 ifValue = ifValue.discardChanges(); | 14299 ifValue = ifValue.discardChanges(); |
| 13939 if (!ifValue) { | 14300 if (!ifValue) { |
| 13940 this.valueChanged(); | 14301 this.valueChanged(); |
| 13941 return; | 14302 return; |
| 13942 } | 14303 } |
| 13943 } | 14304 } |
| 13944 | 14305 |
| 13945 var value = this.deps.value; | 14306 this.updateValue(value); |
| 13946 if (!this.deps.oneTime) | 14307 }, |
| 13947 value = value.discardChanges(); | 14308 |
| 14309 updateValue: function(value) { |
| 13948 if (!this.deps.repeat) | 14310 if (!this.deps.repeat) |
| 13949 value = [value]; | 14311 value = [value]; |
| 13950 var observe = this.deps.repeat && | 14312 var observe = this.deps.repeat && |
| 13951 !this.deps.oneTime && | 14313 !this.deps.oneTime && |
| 13952 Array.isArray(value); | 14314 Array.isArray(value); |
| 13953 this.valueChanged(value, observe); | 14315 this.valueChanged(value, observe); |
| 13954 }, | 14316 }, |
| 13955 | 14317 |
| 13956 valueChanged: function(value, observeValue) { | 14318 valueChanged: function(value, observeValue) { |
| 13957 if (!Array.isArray(value)) | 14319 if (!Array.isArray(value)) |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14227 return imported; | 14589 return imported; |
| 14228 } | 14590 } |
| 14229 } | 14591 } |
| 14230 | 14592 |
| 14231 // exports | 14593 // exports |
| 14232 scope.flush = flush; | 14594 scope.flush = flush; |
| 14233 | 14595 |
| 14234 })(window.Platform); | 14596 })(window.Platform); |
| 14235 | 14597 |
| 14236 | 14598 |
| 14237 //# sourceMappingURL=platform.concat.js.map | 14599 //# sourceMappingURL=platform.concat.js.map |
| OLD | NEW |