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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2095 | 2120 |
2096 var OriginalDOMImplementation = window.DOMImplementation; | 2121 var OriginalDOMImplementation = window.DOMImplementation; |
2097 var OriginalEventTarget = window.EventTarget; | 2122 var OriginalEventTarget = window.EventTarget; |
2098 var OriginalEvent = window.Event; | 2123 var OriginalEvent = window.Event; |
2099 var OriginalNode = window.Node; | 2124 var OriginalNode = window.Node; |
2100 var OriginalWindow = window.Window; | 2125 var OriginalWindow = window.Window; |
2101 var OriginalRange = window.Range; | 2126 var OriginalRange = window.Range; |
2102 var OriginalCanvasRenderingContext2D = window.CanvasRenderingContext2D; | 2127 var OriginalCanvasRenderingContext2D = window.CanvasRenderingContext2D; |
2103 var OriginalWebGLRenderingContext = window.WebGLRenderingContext; | 2128 var OriginalWebGLRenderingContext = window.WebGLRenderingContext; |
2104 var OriginalSVGElementInstance = window.SVGElementInstance; | 2129 var OriginalSVGElementInstance = window.SVGElementInstance; |
2105 | 2130 var OriginalFormData = window.FormData; |
| 2131 |
2106 function isWrapper(object) { | 2132 function isWrapper(object) { |
2107 return object instanceof wrappers.EventTarget || | 2133 return object instanceof wrappers.EventTarget || |
2108 object instanceof wrappers.Event || | 2134 object instanceof wrappers.Event || |
2109 object instanceof wrappers.Range || | 2135 object instanceof wrappers.Range || |
2110 object instanceof wrappers.DOMImplementation || | 2136 object instanceof wrappers.DOMImplementation || |
2111 object instanceof wrappers.CanvasRenderingContext2D || | 2137 object instanceof wrappers.CanvasRenderingContext2D || |
| 2138 object instanceof wrappers.FormData || |
2112 wrappers.WebGLRenderingContext && | 2139 wrappers.WebGLRenderingContext && |
2113 object instanceof wrappers.WebGLRenderingContext; | 2140 object instanceof wrappers.WebGLRenderingContext; |
2114 } | 2141 } |
2115 | 2142 |
2116 function isNative(object) { | 2143 function isNative(object) { |
2117 return OriginalEventTarget && object instanceof OriginalEventTarget || | 2144 return OriginalEventTarget && object instanceof OriginalEventTarget || |
2118 object instanceof OriginalNode || | 2145 object instanceof OriginalNode || |
2119 object instanceof OriginalEvent || | 2146 object instanceof OriginalEvent || |
2120 object instanceof OriginalWindow || | 2147 object instanceof OriginalWindow || |
2121 object instanceof OriginalRange || | 2148 object instanceof OriginalRange || |
2122 object instanceof OriginalDOMImplementation || | 2149 object instanceof OriginalDOMImplementation || |
2123 object instanceof OriginalCanvasRenderingContext2D || | 2150 object instanceof OriginalCanvasRenderingContext2D || |
| 2151 object instanceof OriginalFormData || |
2124 OriginalWebGLRenderingContext && | 2152 OriginalWebGLRenderingContext && |
2125 object instanceof OriginalWebGLRenderingContext || | 2153 object instanceof OriginalWebGLRenderingContext || |
2126 OriginalSVGElementInstance && | 2154 OriginalSVGElementInstance && |
2127 object instanceof OriginalSVGElementInstance; | 2155 object instanceof OriginalSVGElementInstance; |
2128 } | 2156 } |
2129 | 2157 |
2130 /** | 2158 /** |
2131 * Wraps a node in a WrapperNode. If there already exists a wrapper for the | 2159 * Wraps a node in a WrapperNode. If there already exists a wrapper for the |
2132 * |node| that wrapper is returned instead. | 2160 * |node| that wrapper is returned instead. |
2133 * @param {Node} node | 2161 * @param {Node} node |
(...skipping 2443 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 wrap = scope.wrap; |
| 4617 |
| 4618 var originalDocumentQuerySelector = document.querySelector; |
| 4619 var originalElementQuerySelector = document.documentElement.querySelector; |
| 4620 |
| 4621 var originalDocumentQuerySelectorAll = document.querySelectorAll; |
| 4622 var originalElementQuerySelectorAll = document.documentElement.querySelectorAl
l; |
| 4623 |
| 4624 var originalDocumentGetElementsByTagName = document.getElementsByTagName; |
| 4625 var originalElementGetElementsByTagName = document.documentElement.getElements
ByTagName; |
| 4626 |
| 4627 var originalDocumentGetElementsByTagNameNS = document.getElementsByTagNameNS; |
| 4628 var originalElementGetElementsByTagNameNS = document.documentElement.getElemen
tsByTagNameNS; |
| 4629 |
| 4630 var OriginalElement = window.Element; |
| 4631 var OriginalDocument = window.HTMLDocument; |
| 4632 |
| 4633 function filterNodeList(list, index, result) { |
| 4634 var wrappedItem = null; |
| 4635 var root = null; |
| 4636 for (var i = 0, length = list.length; i < length; i++) { |
| 4637 wrappedItem = wrap(list[i]); |
| 4638 if (root = getTreeScope(wrappedItem).root) { |
| 4639 if (root instanceof scope.wrappers.ShadowRoot) { |
| 4640 continue; |
| 4641 } |
| 4642 } |
| 4643 result[index++] = wrappedItem; |
| 4644 } |
| 4645 |
| 4646 return index; |
| 4647 } |
4587 | 4648 |
4588 function findOne(node, selector) { | 4649 function findOne(node, selector) { |
4589 var m, el = node.firstElementChild; | 4650 var m, el = node.firstElementChild; |
4590 while (el) { | 4651 while (el) { |
4591 if (el.matches(selector)) | 4652 if (el.matches(selector)) |
4592 return el; | 4653 return el; |
4593 m = findOne(el, selector); | 4654 m = findOne(el, selector); |
4594 if (m) | 4655 if (m) |
4595 return m; | 4656 return m; |
4596 el = el.nextElementSibling; | 4657 el = el.nextElementSibling; |
(...skipping 10 matching lines...) Expand all Loading... |
4607 function matchesTagName(el, localName, localNameLowerCase) { | 4668 function matchesTagName(el, localName, localNameLowerCase) { |
4608 var ln = el.localName; | 4669 var ln = el.localName; |
4609 return ln === localName || | 4670 return ln === localName || |
4610 ln === localNameLowerCase && el.namespaceURI === XHTML_NS; | 4671 ln === localNameLowerCase && el.namespaceURI === XHTML_NS; |
4611 } | 4672 } |
4612 | 4673 |
4613 function matchesEveryThing() { | 4674 function matchesEveryThing() { |
4614 return true; | 4675 return true; |
4615 } | 4676 } |
4616 | 4677 |
4617 function matchesLocalName(el, localName) { | 4678 function matchesLocalNameOnly(el, ns, localName) { |
4618 return el.localName === localName; | 4679 return el.localName === localName; |
4619 } | 4680 } |
4620 | 4681 |
4621 function matchesNameSpace(el, ns) { | 4682 function matchesNameSpace(el, ns) { |
4622 return el.namespaceURI === ns; | 4683 return el.namespaceURI === ns; |
4623 } | 4684 } |
4624 | 4685 |
4625 function matchesLocalNameNS(el, ns, localName) { | 4686 function matchesLocalNameNS(el, ns, localName) { |
4626 return el.namespaceURI === ns && el.localName === localName; | 4687 return el.namespaceURI === ns && el.localName === localName; |
4627 } | 4688 } |
4628 | 4689 |
4629 function findElements(node, result, p, arg0, arg1) { | 4690 function findElements(node, index, result, p, arg0, arg1) { |
4630 var el = node.firstElementChild; | 4691 var el = node.firstElementChild; |
4631 while (el) { | 4692 while (el) { |
4632 if (p(el, arg0, arg1)) | 4693 if (p(el, arg0, arg1)) |
4633 result[result.length++] = el; | 4694 result[index++] = el; |
4634 findElements(el, result, p, arg0, arg1); | 4695 index = findElements(el, index, result, p, arg0, arg1); |
4635 el = el.nextElementSibling; | 4696 el = el.nextElementSibling; |
4636 } | 4697 } |
4637 return result; | 4698 return index; |
4638 } | 4699 } |
4639 | 4700 |
4640 // find and findAll will only match Simple Selectors, | 4701 // find and findAll will only match Simple Selectors, |
4641 // Structural Pseudo Classes are not guarenteed to be correct | 4702 // Structural Pseudo Classes are not guarenteed to be correct |
4642 // http://www.w3.org/TR/css3-selectors/#simple-selectors | 4703 // http://www.w3.org/TR/css3-selectors/#simple-selectors |
4643 | 4704 |
| 4705 function querySelectorAllFiltered (p, index, result, selector) { |
| 4706 var target = this.impl; |
| 4707 var list; |
| 4708 var root = getTreeScope(this).root; |
| 4709 if (root instanceof scope.wrappers.ShadowRoot) { |
| 4710 // We are in the shadow tree and the logical tree is |
| 4711 // going to be disconnected so we do a manual tree traversal |
| 4712 return findElements(this, index, result, p, selector, null); |
| 4713 } else if (target instanceof OriginalElement) { |
| 4714 list = originalElementQuerySelectorAll.call(target, selector); |
| 4715 } else if (target instanceof OriginalDocument) { |
| 4716 list = originalDocumentQuerySelectorAll.call(target, selector); |
| 4717 } else { |
| 4718 // When we get a ShadowRoot the logical tree is going to be disconnected |
| 4719 // so we do a manual tree traversal |
| 4720 return findElements(this, index, result, p, selector, null); |
| 4721 } |
| 4722 |
| 4723 return filterNodeList(list, index, result); |
| 4724 } |
| 4725 |
4644 var SelectorsInterface = { | 4726 var SelectorsInterface = { |
4645 querySelector: function(selector) { | 4727 querySelector: function(selector) { |
4646 return findOne(this, selector); | 4728 var target = this.impl; |
| 4729 var wrappedItem; |
| 4730 var root = getTreeScope(this).root; |
| 4731 if (root instanceof scope.wrappers.ShadowRoot) { |
| 4732 // We are in the shadow tree and the logical tree is |
| 4733 // going to be disconnected so we do a manual tree traversal |
| 4734 return findOne(this, selector); |
| 4735 } else if (target instanceof OriginalElement) { |
| 4736 wrappedItem = wrap(originalElementQuerySelector.call(target, selector)); |
| 4737 } else if (target instanceof OriginalDocument) { |
| 4738 wrappedItem = wrap(originalDocumentQuerySelector.call(target, selector))
; |
| 4739 } else { |
| 4740 // When we get a ShadowRoot the logical tree is going to be disconnected |
| 4741 // so we do a manual tree traversal |
| 4742 return findOne(this, selector); |
| 4743 } |
| 4744 |
| 4745 if (!wrappedItem) { |
| 4746 // When the original query returns nothing |
| 4747 // we return nothing (to be consistent with the other wrapped calls) |
| 4748 return wrappedItem; |
| 4749 } else if (root = getTreeScope(wrappedItem).root) { |
| 4750 if (root instanceof scope.wrappers.ShadowRoot) { |
| 4751 // When the original query returns an element in the ShadowDOM |
| 4752 // we must do a manual tree traversal |
| 4753 return findOne(this, selector); |
| 4754 } |
| 4755 } |
| 4756 |
| 4757 return wrappedItem; |
4647 }, | 4758 }, |
4648 querySelectorAll: function(selector) { | 4759 querySelectorAll: function(selector) { |
4649 return findElements(this, new NodeList(), matchesSelector, selector); | 4760 var result = new NodeList(); |
| 4761 |
| 4762 result.length = querySelectorAllFiltered.call(this, |
| 4763 matchesSelector, |
| 4764 0, |
| 4765 result, |
| 4766 selector); |
| 4767 |
| 4768 return result; |
4650 } | 4769 } |
4651 }; | 4770 }; |
4652 | 4771 |
| 4772 function getElementsByTagNameFiltered (p, index, result, localName, lowercase)
{ |
| 4773 var target = this.impl; |
| 4774 var list; |
| 4775 var root = getTreeScope(this).root; |
| 4776 if (root instanceof scope.wrappers.ShadowRoot) { |
| 4777 // We are in the shadow tree and the logical tree is |
| 4778 // going to be disconnected so we do a manual tree traversal |
| 4779 return findElements(this, index, result, p, localName, lowercase); |
| 4780 } else if (target instanceof OriginalElement) { |
| 4781 list = originalElementGetElementsByTagName.call(target, localName, lowerca
se); |
| 4782 } else if (target instanceof OriginalDocument) { |
| 4783 list = originalDocumentGetElementsByTagName.call(target, localName, lowerc
ase); |
| 4784 } else { |
| 4785 // When we get a ShadowRoot the logical tree is going to be disconnected |
| 4786 // so we do a manual tree traversal |
| 4787 return findElements(this, index, result, p, localName, lowercase); |
| 4788 } |
| 4789 |
| 4790 return filterNodeList(list, index, result); |
| 4791 } |
| 4792 |
| 4793 function getElementsByTagNameNSFiltered (p, index, result, ns, localName) { |
| 4794 var target = this.impl; |
| 4795 var list; |
| 4796 var root = getTreeScope(this).root; |
| 4797 if (root instanceof scope.wrappers.ShadowRoot) { |
| 4798 // We are in the shadow tree and the logical tree is |
| 4799 // going to be disconnected so we do a manual tree traversal |
| 4800 return findElements(this, index, result, p, ns, localName); |
| 4801 } else if (target instanceof OriginalElement) { |
| 4802 list = originalElementGetElementsByTagNameNS.call(target, ns, localName); |
| 4803 } else if (target instanceof OriginalDocument) { |
| 4804 list = originalDocumentGetElementsByTagNameNS.call(target, ns, localName); |
| 4805 } else { |
| 4806 // When we get a ShadowRoot the logical tree is going to be disconnected |
| 4807 // so we do a manual tree traversal |
| 4808 return findElements(this, index, result, p, ns, localName); |
| 4809 } |
| 4810 |
| 4811 return filterNodeList(list, index, result); |
| 4812 } |
| 4813 |
4653 var GetElementsByInterface = { | 4814 var GetElementsByInterface = { |
4654 getElementsByTagName: function(localName) { | 4815 getElementsByTagName: function(localName) { |
4655 var result = new HTMLCollection(); | 4816 var result = new HTMLCollection(); |
4656 if (localName === '*') | 4817 var match = localName === '*' ? matchesEveryThing : matchesTagName; |
4657 return findElements(this, result, matchesEveryThing); | |
4658 | 4818 |
4659 return findElements(this, result, | 4819 result.length = getElementsByTagNameFiltered.call(this, |
4660 matchesTagName, | 4820 match, |
| 4821 0, |
| 4822 result, |
4661 localName, | 4823 localName, |
4662 localName.toLowerCase()); | 4824 localName.toLowerCase()); |
| 4825 |
| 4826 return result; |
4663 }, | 4827 }, |
4664 | 4828 |
4665 getElementsByClassName: function(className) { | 4829 getElementsByClassName: function(className) { |
4666 // TODO(arv): Check className? | 4830 // TODO(arv): Check className? |
4667 return this.querySelectorAll('.' + className); | 4831 return this.querySelectorAll('.' + className); |
4668 }, | 4832 }, |
4669 | 4833 |
4670 getElementsByTagNameNS: function(ns, localName) { | 4834 getElementsByTagNameNS: function(ns, localName) { |
4671 var result = new HTMLCollection(); | 4835 var result = new HTMLCollection(); |
| 4836 var match = null; |
4672 | 4837 |
4673 if (ns === '') { | 4838 if (ns === '*') { |
4674 ns = null; | 4839 match = localName === '*' ? matchesEveryThing : matchesLocalNameOnly; |
4675 } else if (ns === '*') { | 4840 } else { |
4676 if (localName === '*') | 4841 match = localName === '*' ? matchesNameSpace : matchesLocalNameNS; |
4677 return findElements(this, result, matchesEveryThing); | |
4678 return findElements(this, result, matchesLocalName, localName); | |
4679 } | 4842 } |
| 4843 |
| 4844 result.length = getElementsByTagNameNSFiltered.call(this, |
| 4845 match, |
| 4846 0, |
| 4847 result, |
| 4848 ns || null, |
| 4849 localName); |
4680 | 4850 |
4681 if (localName === '*') | 4851 return result; |
4682 return findElements(this, result, matchesNameSpace, ns); | |
4683 | |
4684 return findElements(this, result, matchesLocalNameNS, ns, localName); | |
4685 } | 4852 } |
4686 }; | 4853 }; |
4687 | 4854 |
4688 scope.GetElementsByInterface = GetElementsByInterface; | 4855 scope.GetElementsByInterface = GetElementsByInterface; |
4689 scope.SelectorsInterface = SelectorsInterface; | 4856 scope.SelectorsInterface = SelectorsInterface; |
4690 | 4857 |
4691 })(window.ShadowDOMPolyfill); | 4858 })(window.ShadowDOMPolyfill); |
4692 | 4859 |
4693 // Copyright 2013 The Polymer Authors. All rights reserved. | 4860 // Copyright 2013 The Polymer Authors. All rights reserved. |
4694 // Use of this source code is goverened by a BSD-style | 4861 // Use of this source code is goverened by a BSD-style |
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5278 case 'beforeend': | 5445 case 'beforeend': |
5279 contextElement = this; | 5446 contextElement = this; |
5280 refNode = null; | 5447 refNode = null; |
5281 break; | 5448 break; |
5282 default: | 5449 default: |
5283 return; | 5450 return; |
5284 } | 5451 } |
5285 | 5452 |
5286 var df = frag(contextElement, text); | 5453 var df = frag(contextElement, text); |
5287 contextElement.insertBefore(df, refNode); | 5454 contextElement.insertBefore(df, refNode); |
| 5455 }, |
| 5456 |
| 5457 get hidden() { |
| 5458 return this.hasAttribute('hidden'); |
| 5459 }, |
| 5460 set hidden(v) { |
| 5461 if (v) { |
| 5462 this.setAttribute('hidden', ''); |
| 5463 } else { |
| 5464 this.removeAttribute('hidden'); |
| 5465 } |
5288 } | 5466 } |
5289 }); | 5467 }); |
5290 | 5468 |
5291 function frag(contextElement, html) { | 5469 function frag(contextElement, html) { |
5292 // TODO(arv): This does not work with SVG and other non HTML elements. | 5470 // TODO(arv): This does not work with SVG and other non HTML elements. |
5293 var p = unwrap(contextElement.cloneNode(false)); | 5471 var p = unwrap(contextElement.cloneNode(false)); |
5294 p.innerHTML = html; | 5472 p.innerHTML = html; |
5295 var df = unwrap(document.createDocumentFragment()); | 5473 var df = unwrap(document.createDocumentFragment()); |
5296 var c; | 5474 var c; |
5297 while (c = p.firstChild) { | 5475 while (c = p.firstChild) { |
(...skipping 2232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7530 var Selection = scope.wrappers.Selection; | 7708 var Selection = scope.wrappers.Selection; |
7531 var mixin = scope.mixin; | 7709 var mixin = scope.mixin; |
7532 var registerWrapper = scope.registerWrapper; | 7710 var registerWrapper = scope.registerWrapper; |
7533 var renderAllPending = scope.renderAllPending; | 7711 var renderAllPending = scope.renderAllPending; |
7534 var unwrap = scope.unwrap; | 7712 var unwrap = scope.unwrap; |
7535 var unwrapIfNeeded = scope.unwrapIfNeeded; | 7713 var unwrapIfNeeded = scope.unwrapIfNeeded; |
7536 var wrap = scope.wrap; | 7714 var wrap = scope.wrap; |
7537 | 7715 |
7538 var OriginalWindow = window.Window; | 7716 var OriginalWindow = window.Window; |
7539 var originalGetComputedStyle = window.getComputedStyle; | 7717 var originalGetComputedStyle = window.getComputedStyle; |
| 7718 var originalGetDefaultComputedStyle = window.getDefaultComputedStyle; |
7540 var originalGetSelection = window.getSelection; | 7719 var originalGetSelection = window.getSelection; |
7541 | 7720 |
7542 function Window(impl) { | 7721 function Window(impl) { |
7543 EventTarget.call(this, impl); | 7722 EventTarget.call(this, impl); |
7544 } | 7723 } |
7545 Window.prototype = Object.create(EventTarget.prototype); | 7724 Window.prototype = Object.create(EventTarget.prototype); |
7546 | 7725 |
7547 OriginalWindow.prototype.getComputedStyle = function(el, pseudo) { | 7726 OriginalWindow.prototype.getComputedStyle = function(el, pseudo) { |
7548 return wrap(this || window).getComputedStyle(unwrapIfNeeded(el), pseudo); | 7727 return wrap(this || window).getComputedStyle(unwrapIfNeeded(el), pseudo); |
7549 }; | 7728 }; |
7550 | 7729 |
| 7730 // Mozilla proprietary extension. |
| 7731 if (originalGetDefaultComputedStyle) { |
| 7732 OriginalWindow.prototype.getDefaultComputedStyle = function(el, pseudo) { |
| 7733 return wrap(this || window).getDefaultComputedStyle( |
| 7734 unwrapIfNeeded(el), pseudo); |
| 7735 }; |
| 7736 } |
| 7737 |
7551 OriginalWindow.prototype.getSelection = function() { | 7738 OriginalWindow.prototype.getSelection = function() { |
7552 return wrap(this || window).getSelection(); | 7739 return wrap(this || window).getSelection(); |
7553 }; | 7740 }; |
7554 | 7741 |
7555 // Work around for https://bugzilla.mozilla.org/show_bug.cgi?id=943065 | 7742 // Work around for https://bugzilla.mozilla.org/show_bug.cgi?id=943065 |
7556 delete window.getComputedStyle; | 7743 delete window.getComputedStyle; |
7557 delete window.getSelection; | 7744 delete window.getSelection; |
7558 | 7745 |
7559 ['addEventListener', 'removeEventListener', 'dispatchEvent'].forEach( | 7746 ['addEventListener', 'removeEventListener', 'dispatchEvent'].forEach( |
7560 function(name) { | 7747 function(name) { |
(...skipping 15 matching lines...) Expand all Loading... |
7576 getSelection: function() { | 7763 getSelection: function() { |
7577 renderAllPending(); | 7764 renderAllPending(); |
7578 return new Selection(originalGetSelection.call(unwrap(this))); | 7765 return new Selection(originalGetSelection.call(unwrap(this))); |
7579 }, | 7766 }, |
7580 | 7767 |
7581 get document() { | 7768 get document() { |
7582 return wrap(unwrap(this).document); | 7769 return wrap(unwrap(this).document); |
7583 } | 7770 } |
7584 }); | 7771 }); |
7585 | 7772 |
| 7773 // Mozilla proprietary extension. |
| 7774 if (originalGetDefaultComputedStyle) { |
| 7775 Window.prototype.getDefaultComputedStyle = function(el, pseudo) { |
| 7776 renderAllPending(); |
| 7777 return originalGetDefaultComputedStyle.call(unwrap(this), |
| 7778 unwrapIfNeeded(el),pseudo); |
| 7779 }; |
| 7780 } |
| 7781 |
7586 registerWrapper(OriginalWindow, Window, window); | 7782 registerWrapper(OriginalWindow, Window, window); |
7587 | 7783 |
7588 scope.wrappers.Window = Window; | 7784 scope.wrappers.Window = Window; |
7589 | 7785 |
7590 })(window.ShadowDOMPolyfill); | 7786 })(window.ShadowDOMPolyfill); |
7591 | 7787 |
7592 /** | 7788 /** |
7593 * Copyright 2014 The Polymer Authors. All rights reserved. | 7789 * Copyright 2014 The Polymer Authors. All rights reserved. |
7594 * Use of this source code is goverened by a BSD-style | 7790 * Use of this source code is goverened by a BSD-style |
7595 * license that can be found in the LICENSE file. | 7791 * license that can be found in the LICENSE file. |
(...skipping 28 matching lines...) Expand all Loading... |
7624 | 7820 |
7625 (function(scope) { | 7821 (function(scope) { |
7626 'use strict'; | 7822 'use strict'; |
7627 | 7823 |
7628 var registerWrapper = scope.registerWrapper; | 7824 var registerWrapper = scope.registerWrapper; |
7629 var unwrap = scope.unwrap; | 7825 var unwrap = scope.unwrap; |
7630 | 7826 |
7631 var OriginalFormData = window.FormData; | 7827 var OriginalFormData = window.FormData; |
7632 | 7828 |
7633 function FormData(formElement) { | 7829 function FormData(formElement) { |
7634 this.impl = new OriginalFormData(formElement && unwrap(formElement)); | 7830 if (formElement instanceof OriginalFormData) |
| 7831 this.impl = formElement; |
| 7832 else |
| 7833 this.impl = new OriginalFormData(formElement && unwrap(formElement)); |
7635 } | 7834 } |
7636 | 7835 |
7637 registerWrapper(OriginalFormData, FormData, new OriginalFormData()); | 7836 registerWrapper(OriginalFormData, FormData, new OriginalFormData()); |
7638 | 7837 |
7639 scope.wrappers.FormData = FormData; | 7838 scope.wrappers.FormData = FormData; |
7640 | 7839 |
7641 })(window.ShadowDOMPolyfill); | 7840 })(window.ShadowDOMPolyfill); |
7642 | 7841 |
7643 // Copyright 2013 The Polymer Authors. All rights reserved. | 7842 // Copyright 2013 The Polymer Authors. All rights reserved. |
7644 // Use of this source code is goverened by a BSD-style | 7843 // 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 { | 8587 } else { |
8389 addCssToDocument(cssText); | 8588 addCssToDocument(cssText); |
8390 } | 8589 } |
8391 } | 8590 } |
8392 }; | 8591 }; |
8393 | 8592 |
8394 var selectorRe = /([^{]*)({[\s\S]*?})/gim, | 8593 var selectorRe = /([^{]*)({[\s\S]*?})/gim, |
8395 cssCommentRe = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//gim, | 8594 cssCommentRe = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//gim, |
8396 // TODO(sorvell): remove either content or comment | 8595 // TODO(sorvell): remove either content or comment |
8397 cssCommentNextSelectorRe = /\/\*\s*@polyfill ([^*]*\*+([^/*][^*]*\*+)*\/)([^
{]*?){/gim, | 8596 cssCommentNextSelectorRe = /\/\*\s*@polyfill ([^*]*\*+([^/*][^*]*\*+)*\/)([^
{]*?){/gim, |
8398 cssContentNextSelectorRe = /polyfill-next-selector[^}]*content\:[\s]*['|"]([
^'"]*)['|"][^}]*}([^{]*?){/gim, | 8597 cssContentNextSelectorRe = /polyfill-next-selector[^}]*content\:[\s]*?['"](.
*?)['"][;\s]*}([^{]*?){/gim, |
8399 // TODO(sorvell): remove either content or comment | 8598 // TODO(sorvell): remove either content or comment |
8400 cssCommentRuleRe = /\/\*\s@polyfill-rule([^*]*\*+([^/*][^*]*\*+)*)\//gim, | 8599 cssCommentRuleRe = /\/\*\s@polyfill-rule([^*]*\*+([^/*][^*]*\*+)*)\//gim, |
8401 cssContentRuleRe = /(polyfill-rule)[^}]*(content\:[\s]*['|"]([^'"]*)['|"][^;
]*;)[^}]*}/gim, | 8600 cssContentRuleRe = /(polyfill-rule)[^}]*(content\:[\s]*['"](.*?)['"])[;\s]*[
^}]*}/gim, |
8402 // TODO(sorvell): remove either content or comment | 8601 // TODO(sorvell): remove either content or comment |
8403 cssCommentUnscopedRuleRe = /\/\*\s@polyfill-unscoped-rule([^*]*\*+([^/*][^*]
*\*+)*)\//gim, | 8602 cssCommentUnscopedRuleRe = /\/\*\s@polyfill-unscoped-rule([^*]*\*+([^/*][^*]
*\*+)*)\//gim, |
8404 cssContentUnscopedRuleRe = /(polyfill-unscoped-rule)[^}]*(content\:[\s]*['|"
]([^'"]*)['|"][^;]*;)[^}]*}/gim, | 8603 cssContentUnscopedRuleRe = /(polyfill-unscoped-rule)[^}]*(content\:[\s]*['"]
(.*?)['"])[;\s]*[^}]*}/gim, |
8405 cssPseudoRe = /::(x-[^\s{,(]*)/gim, | 8604 cssPseudoRe = /::(x-[^\s{,(]*)/gim, |
8406 cssPartRe = /::part\(([^)]*)\)/gim, | 8605 cssPartRe = /::part\(([^)]*)\)/gim, |
8407 // note: :host pre-processed to -shadowcsshost. | 8606 // note: :host pre-processed to -shadowcsshost. |
8408 polyfillHost = '-shadowcsshost', | 8607 polyfillHost = '-shadowcsshost', |
8409 // note: :host-context pre-processed to -shadowcsshostcontext. | 8608 // note: :host-context pre-processed to -shadowcsshostcontext. |
8410 polyfillHostContext = '-shadowcsscontext', | 8609 polyfillHostContext = '-shadowcsscontext', |
8411 parenSuffix = ')(?:\\((' + | 8610 parenSuffix = ')(?:\\((' + |
8412 '(?:\\([^)(]*\\)|[^)(]*)+?' + | 8611 '(?:\\([^)(]*\\)|[^)(]*)+?' + |
8413 ')\\))?([^,{]*)'; | 8612 ')\\))?([^,{]*)'; |
8414 cssColonHostRe = new RegExp('(' + polyfillHost + parenSuffix, 'gim'), | 8613 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); | 8789 style.textContent = ShadowCSS.shimStyle(style); |
8591 style.removeAttribute(SHIM_ATTRIBUTE, ''); | 8790 style.removeAttribute(SHIM_ATTRIBUTE, ''); |
8592 style.setAttribute(SHIMMED_ATTRIBUTE, ''); | 8791 style.setAttribute(SHIMMED_ATTRIBUTE, ''); |
8593 style[SHIMMED_ATTRIBUTE] = true; | 8792 style[SHIMMED_ATTRIBUTE] = true; |
8594 // place in document | 8793 // place in document |
8595 if (style.parentNode !== head) { | 8794 if (style.parentNode !== head) { |
8596 // replace links in head | 8795 // replace links in head |
8597 if (elt.parentNode === head) { | 8796 if (elt.parentNode === head) { |
8598 head.replaceChild(style, elt); | 8797 head.replaceChild(style, elt); |
8599 } else { | 8798 } else { |
8600 head.appendChild(style); | 8799 this.addElementToDocument(style); |
8601 } | 8800 } |
8602 } | 8801 } |
8603 style.__importParsed = true; | 8802 style.__importParsed = true; |
8604 this.markParsingComplete(elt); | 8803 this.markParsingComplete(elt); |
8605 this.parseNext(); | 8804 this.parseNext(); |
8606 } | 8805 } |
8607 | 8806 |
8608 var hasResource = HTMLImports.parser.hasResource; | 8807 var hasResource = HTMLImports.parser.hasResource; |
8609 HTMLImports.parser.hasResource = function(node) { | 8808 HTMLImports.parser.hasResource = function(node) { |
8610 if (node.localName === 'link' && node.rel === 'stylesheet' && | 8809 if (node.localName === 'link' && node.rel === 'stylesheet' && |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8665 frag.appendChild(inTemplate.firstChild); | 8864 frag.appendChild(inTemplate.firstChild); |
8666 } | 8865 } |
8667 inTemplate._content = frag; | 8866 inTemplate._content = frag; |
8668 } | 8867 } |
8669 return inTemplate.content || inTemplate._content; | 8868 return inTemplate.content || inTemplate._content; |
8670 }; | 8869 }; |
8671 | 8870 |
8672 })(window.Platform); | 8871 })(window.Platform); |
8673 | 8872 |
8674 } | 8873 } |
8675 /* Any copyright is dedicated to the Public Domain. | |
8676 * http://creativecommons.org/publicdomain/zero/1.0/ */ | |
8677 | |
8678 (function(scope) { | |
8679 'use strict'; | |
8680 | |
8681 // feature detect for URL constructor | |
8682 var hasWorkingUrl = false; | |
8683 if (!scope.forceJURL) { | |
8684 try { | |
8685 var u = new URL('b', 'http://a'); | |
8686 hasWorkingUrl = u.href === 'http://a/b'; | |
8687 } catch(e) {} | |
8688 } | |
8689 | |
8690 if (hasWorkingUrl) | |
8691 return; | |
8692 | |
8693 var relative = Object.create(null); | |
8694 relative['ftp'] = 21; | |
8695 relative['file'] = 0; | |
8696 relative['gopher'] = 70; | |
8697 relative['http'] = 80; | |
8698 relative['https'] = 443; | |
8699 relative['ws'] = 80; | |
8700 relative['wss'] = 443; | |
8701 | |
8702 var relativePathDotMapping = Object.create(null); | |
8703 relativePathDotMapping['%2e'] = '.'; | |
8704 relativePathDotMapping['.%2e'] = '..'; | |
8705 relativePathDotMapping['%2e.'] = '..'; | |
8706 relativePathDotMapping['%2e%2e'] = '..'; | |
8707 | |
8708 function isRelativeScheme(scheme) { | |
8709 return relative[scheme] !== undefined; | |
8710 } | |
8711 | |
8712 function invalid() { | |
8713 clear.call(this); | |
8714 this._isInvalid = true; | |
8715 } | |
8716 | |
8717 function IDNAToASCII(h) { | |
8718 if ('' == h) { | |
8719 invalid.call(this) | |
8720 } | |
8721 // XXX | |
8722 return h.toLowerCase() | |
8723 } | |
8724 | |
8725 function percentEscape(c) { | |
8726 var unicode = c.charCodeAt(0); | |
8727 if (unicode > 0x20 && | |
8728 unicode < 0x7F && | |
8729 // " # < > ? ` | |
8730 [0x22, 0x23, 0x3C, 0x3E, 0x3F, 0x60].indexOf(unicode) == -1 | |
8731 ) { | |
8732 return c; | |
8733 } | |
8734 return encodeURIComponent(c); | |
8735 } | |
8736 | |
8737 function percentEscapeQuery(c) { | |
8738 // XXX This actually needs to encode c using encoding and then | |
8739 // convert the bytes one-by-one. | |
8740 | |
8741 var unicode = c.charCodeAt(0); | |
8742 if (unicode > 0x20 && | |
8743 unicode < 0x7F && | |
8744 // " # < > ` (do not escape '?') | |
8745 [0x22, 0x23, 0x3C, 0x3E, 0x60].indexOf(unicode) == -1 | |
8746 ) { | |
8747 return c; | |
8748 } | |
8749 return encodeURIComponent(c); | |
8750 } | |
8751 | |
8752 var EOF = undefined, | |
8753 ALPHA = /[a-zA-Z]/, | |
8754 ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/; | |
8755 | |
8756 function parse(input, stateOverride, base) { | |
8757 function err(message) { | |
8758 errors.push(message) | |
8759 } | |
8760 | |
8761 var state = stateOverride || 'scheme start', | |
8762 cursor = 0, | |
8763 buffer = '', | |
8764 seenAt = false, | |
8765 seenBracket = false, | |
8766 errors = []; | |
8767 | |
8768 loop: while ((input[cursor - 1] != EOF || cursor == 0) && !this._isInvalid)
{ | |
8769 var c = input[cursor]; | |
8770 switch (state) { | |
8771 case 'scheme start': | |
8772 if (c && ALPHA.test(c)) { | |
8773 buffer += c.toLowerCase(); // ASCII-safe | |
8774 state = 'scheme'; | |
8775 } else if (!stateOverride) { | |
8776 buffer = ''; | |
8777 state = 'no scheme'; | |
8778 continue; | |
8779 } else { | |
8780 err('Invalid scheme.'); | |
8781 break loop; | |
8782 } | |
8783 break; | |
8784 | |
8785 case 'scheme': | |
8786 if (c && ALPHANUMERIC.test(c)) { | |
8787 buffer += c.toLowerCase(); // ASCII-safe | |
8788 } else if (':' == c) { | |
8789 this._scheme = buffer; | |
8790 buffer = ''; | |
8791 if (stateOverride) { | |
8792 break loop; | |
8793 } | |
8794 if (isRelativeScheme(this._scheme)) { | |
8795 this._isRelative = true; | |
8796 } | |
8797 if ('file' == this._scheme) { | |
8798 state = 'relative'; | |
8799 } else if (this._isRelative && base && base._scheme == this._scheme)
{ | |
8800 state = 'relative or authority'; | |
8801 } else if (this._isRelative) { | |
8802 state = 'authority first slash'; | |
8803 } else { | |
8804 state = 'scheme data'; | |
8805 } | |
8806 } else if (!stateOverride) { | |
8807 buffer = ''; | |
8808 cursor = 0; | |
8809 state = 'no scheme'; | |
8810 continue; | |
8811 } else if (EOF == c) { | |
8812 break loop; | |
8813 } else { | |
8814 err('Code point not allowed in scheme: ' + c) | |
8815 break loop; | |
8816 } | |
8817 break; | |
8818 | |
8819 case 'scheme data': | |
8820 if ('?' == c) { | |
8821 query = '?'; | |
8822 state = 'query'; | |
8823 } else if ('#' == c) { | |
8824 this._fragment = '#'; | |
8825 state = 'fragment'; | |
8826 } else { | |
8827 // XXX error handling | |
8828 if (EOF != c && '\t' != c && '\n' != c && '\r' != c) { | |
8829 this._schemeData += percentEscape(c); | |
8830 } | |
8831 } | |
8832 break; | |
8833 | |
8834 case 'no scheme': | |
8835 if (!base || !(isRelativeScheme(base._scheme))) { | |
8836 err('Missing scheme.'); | |
8837 invalid.call(this); | |
8838 } else { | |
8839 state = 'relative'; | |
8840 continue; | |
8841 } | |
8842 break; | |
8843 | |
8844 case 'relative or authority': | |
8845 if ('/' == c && '/' == input[cursor+1]) { | |
8846 state = 'authority ignore slashes'; | |
8847 } else { | |
8848 err('Expected /, got: ' + c); | |
8849 state = 'relative'; | |
8850 continue | |
8851 } | |
8852 break; | |
8853 | |
8854 case 'relative': | |
8855 this._isRelative = true; | |
8856 if ('file' != this._scheme) | |
8857 this._scheme = base._scheme; | |
8858 if (EOF == c) { | |
8859 this._host = base._host; | |
8860 this._port = base._port; | |
8861 this._path = base._path.slice(); | |
8862 this._query = base._query; | |
8863 break loop; | |
8864 } else if ('/' == c || '\\' == c) { | |
8865 if ('\\' == c) | |
8866 err('\\ is an invalid code point.'); | |
8867 state = 'relative slash'; | |
8868 } else if ('?' == c) { | |
8869 this._host = base._host; | |
8870 this._port = base._port; | |
8871 this._path = base._path.slice(); | |
8872 this._query = '?'; | |
8873 state = 'query'; | |
8874 } else if ('#' == c) { | |
8875 this._host = base._host; | |
8876 this._port = base._port; | |
8877 this._path = base._path.slice(); | |
8878 this._query = base._query; | |
8879 this._fragment = '#'; | |
8880 state = 'fragment'; | |
8881 } else { | |
8882 var nextC = input[cursor+1] | |
8883 var nextNextC = input[cursor+2] | |
8884 if ( | |
8885 'file' != this._scheme || !ALPHA.test(c) || | |
8886 (nextC != ':' && nextC != '|') || | |
8887 (EOF != nextNextC && '/' != nextNextC && '\\' != nextNextC && '?'
!= nextNextC && '#' != nextNextC)) { | |
8888 this._host = base._host; | |
8889 this._port = base._port; | |
8890 this._path = base._path.slice(); | |
8891 this._path.pop(); | |
8892 } | |
8893 state = 'relative path'; | |
8894 continue; | |
8895 } | |
8896 break; | |
8897 | |
8898 case 'relative slash': | |
8899 if ('/' == c || '\\' == c) { | |
8900 if ('\\' == c) { | |
8901 err('\\ is an invalid code point.'); | |
8902 } | |
8903 if ('file' == this._scheme) { | |
8904 state = 'file host'; | |
8905 } else { | |
8906 state = 'authority ignore slashes'; | |
8907 } | |
8908 } else { | |
8909 if ('file' != this._scheme) { | |
8910 this._host = base._host; | |
8911 this._port = base._port; | |
8912 } | |
8913 state = 'relative path'; | |
8914 continue; | |
8915 } | |
8916 break; | |
8917 | |
8918 case 'authority first slash': | |
8919 if ('/' == c) { | |
8920 state = 'authority second slash'; | |
8921 } else { | |
8922 err("Expected '/', got: " + c); | |
8923 state = 'authority ignore slashes'; | |
8924 continue; | |
8925 } | |
8926 break; | |
8927 | |
8928 case 'authority second slash': | |
8929 state = 'authority ignore slashes'; | |
8930 if ('/' != c) { | |
8931 err("Expected '/', got: " + c); | |
8932 continue; | |
8933 } | |
8934 break; | |
8935 | |
8936 case 'authority ignore slashes': | |
8937 if ('/' != c && '\\' != c) { | |
8938 state = 'authority'; | |
8939 continue; | |
8940 } else { | |
8941 err('Expected authority, got: ' + c); | |
8942 } | |
8943 break; | |
8944 | |
8945 case 'authority': | |
8946 if ('@' == c) { | |
8947 if (seenAt) { | |
8948 err('@ already seen.'); | |
8949 buffer += '%40'; | |
8950 } | |
8951 seenAt = true; | |
8952 for (var i = 0; i < buffer.length; i++) { | |
8953 var cp = buffer[i]; | |
8954 if ('\t' == cp || '\n' == cp || '\r' == cp) { | |
8955 err('Invalid whitespace in authority.'); | |
8956 continue; | |
8957 } | |
8958 // XXX check URL code points | |
8959 if (':' == cp && null === this._password) { | |
8960 this._password = ''; | |
8961 continue; | |
8962 } | |
8963 var tempC = percentEscape(cp); | |
8964 (null !== this._password) ? this._password += tempC : this._userna
me += tempC; | |
8965 } | |
8966 buffer = ''; | |
8967 } else if (EOF == c || '/' == c || '\\' == c || '?' == c || '#' == c)
{ | |
8968 cursor -= buffer.length; | |
8969 buffer = ''; | |
8970 state = 'host'; | |
8971 continue; | |
8972 } else { | |
8973 buffer += c; | |
8974 } | |
8975 break; | |
8976 | |
8977 case 'file host': | |
8978 if (EOF == c || '/' == c || '\\' == c || '?' == c || '#' == c) { | |
8979 if (buffer.length == 2 && ALPHA.test(buffer[0]) && (buffer[1] == ':'
|| buffer[1] == '|')) { | |
8980 state = 'relative path'; | |
8981 } else if (buffer.length == 0) { | |
8982 state = 'relative path start'; | |
8983 } else { | |
8984 this._host = IDNAToASCII.call(this, buffer); | |
8985 buffer = ''; | |
8986 state = 'relative path start'; | |
8987 } | |
8988 continue; | |
8989 } else if ('\t' == c || '\n' == c || '\r' == c) { | |
8990 err('Invalid whitespace in file host.'); | |
8991 } else { | |
8992 buffer += c; | |
8993 } | |
8994 break; | |
8995 | |
8996 case 'host': | |
8997 case 'hostname': | |
8998 if (':' == c && !seenBracket) { | |
8999 // XXX host parsing | |
9000 this._host = IDNAToASCII.call(this, buffer); | |
9001 buffer = ''; | |
9002 state = 'port'; | |
9003 if ('hostname' == stateOverride) { | |
9004 break loop; | |
9005 } | |
9006 } else if (EOF == c || '/' == c || '\\' == c || '?' == c || '#' == c)
{ | |
9007 this._host = IDNAToASCII.call(this, buffer); | |
9008 buffer = ''; | |
9009 state = 'relative path start'; | |
9010 if (stateOverride) { | |
9011 break loop; | |
9012 } | |
9013 continue; | |
9014 } else if ('\t' != c && '\n' != c && '\r' != c) { | |
9015 if ('[' == c) { | |
9016 seenBracket = true; | |
9017 } else if (']' == c) { | |
9018 seenBracket = false; | |
9019 } | |
9020 buffer += c; | |
9021 } else { | |
9022 err('Invalid code point in host/hostname: ' + c); | |
9023 } | |
9024 break; | |
9025 | |
9026 case 'port': | |
9027 if (/[0-9]/.test(c)) { | |
9028 buffer += c; | |
9029 } else if (EOF == c || '/' == c || '\\' == c || '?' == c || '#' == c |
| stateOverride) { | |
9030 if ('' != buffer) { | |
9031 var temp = parseInt(buffer, 10); | |
9032 if (temp != relative[this._scheme]) { | |
9033 this._port = temp + ''; | |
9034 } | |
9035 buffer = ''; | |
9036 } | |
9037 if (stateOverride) { | |
9038 break loop; | |
9039 } | |
9040 state = 'relative path start'; | |
9041 continue; | |
9042 } else if ('\t' == c || '\n' == c || '\r' == c) { | |
9043 err('Invalid code point in port: ' + c); | |
9044 } else { | |
9045 invalid.call(this); | |
9046 } | |
9047 break; | |
9048 | |
9049 case 'relative path start': | |
9050 if ('\\' == c) | |
9051 err("'\\' not allowed in path."); | |
9052 state = 'relative path'; | |
9053 if ('/' != c && '\\' != c) { | |
9054 continue; | |
9055 } | |
9056 break; | |
9057 | |
9058 case 'relative path': | |
9059 if (EOF == c || '/' == c || '\\' == c || (!stateOverride && ('?' == c
|| '#' == c))) { | |
9060 if ('\\' == c) { | |
9061 err('\\ not allowed in relative path.'); | |
9062 } | |
9063 var tmp; | |
9064 if (tmp = relativePathDotMapping[buffer.toLowerCase()]) { | |
9065 buffer = tmp; | |
9066 } | |
9067 if ('..' == buffer) { | |
9068 this._path.pop(); | |
9069 if ('/' != c && '\\' != c) { | |
9070 this._path.push(''); | |
9071 } | |
9072 } else if ('.' == buffer && '/' != c && '\\' != c) { | |
9073 this._path.push(''); | |
9074 } else if ('.' != buffer) { | |
9075 if ('file' == this._scheme && this._path.length == 0 && buffer.len
gth == 2 && ALPHA.test(buffer[0]) && buffer[1] == '|') { | |
9076 buffer = buffer[0] + ':'; | |
9077 } | |
9078 this._path.push(buffer); | |
9079 } | |
9080 buffer = ''; | |
9081 if ('?' == c) { | |
9082 this._query = '?'; | |
9083 state = 'query'; | |
9084 } else if ('#' == c) { | |
9085 this._fragment = '#'; | |
9086 state = 'fragment'; | |
9087 } | |
9088 } else if ('\t' != c && '\n' != c && '\r' != c) { | |
9089 buffer += percentEscape(c); | |
9090 } | |
9091 break; | |
9092 | |
9093 case 'query': | |
9094 if (!stateOverride && '#' == c) { | |
9095 this._fragment = '#'; | |
9096 state = 'fragment'; | |
9097 } else if (EOF != c && '\t' != c && '\n' != c && '\r' != c) { | |
9098 this._query += percentEscapeQuery(c); | |
9099 } | |
9100 break; | |
9101 | |
9102 case 'fragment': | |
9103 if (EOF != c && '\t' != c && '\n' != c && '\r' != c) { | |
9104 this._fragment += c; | |
9105 } | |
9106 break; | |
9107 } | |
9108 | |
9109 cursor++; | |
9110 } | |
9111 } | |
9112 | |
9113 function clear() { | |
9114 this._scheme = ''; | |
9115 this._schemeData = ''; | |
9116 this._username = ''; | |
9117 this._password = null; | |
9118 this._host = ''; | |
9119 this._port = ''; | |
9120 this._path = []; | |
9121 this._query = ''; | |
9122 this._fragment = ''; | |
9123 this._isInvalid = false; | |
9124 this._isRelative = false; | |
9125 } | |
9126 | |
9127 // Does not process domain names or IP addresses. | |
9128 // Does not handle encoding for the query parameter. | |
9129 function jURL(url, base /* , encoding */) { | |
9130 if (base !== undefined && !(base instanceof jURL)) | |
9131 base = new jURL(String(base)); | |
9132 | |
9133 this._url = url; | |
9134 clear.call(this); | |
9135 | |
9136 var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, ''); | |
9137 // encoding = encoding || 'utf-8' | |
9138 | |
9139 parse.call(this, input, null, base); | |
9140 } | |
9141 | |
9142 jURL.prototype = { | |
9143 get href() { | |
9144 if (this._isInvalid) | |
9145 return this._url; | |
9146 | |
9147 var authority = ''; | |
9148 if ('' != this._username || null != this._password) { | |
9149 authority = this._username + | |
9150 (null != this._password ? ':' + this._password : '') + '@'; | |
9151 } | |
9152 | |
9153 return this.protocol + | |
9154 (this._isRelative ? '//' + authority + this.host : '') + | |
9155 this.pathname + this._query + this._fragment; | |
9156 }, | |
9157 set href(href) { | |
9158 clear.call(this); | |
9159 parse.call(this, href); | |
9160 }, | |
9161 | |
9162 get protocol() { | |
9163 return this._scheme + ':'; | |
9164 }, | |
9165 set protocol(protocol) { | |
9166 if (this._isInvalid) | |
9167 return; | |
9168 parse.call(this, protocol + ':', 'scheme start'); | |
9169 }, | |
9170 | |
9171 get host() { | |
9172 return this._isInvalid ? '' : this._port ? | |
9173 this._host + ':' + this._port : this._host; | |
9174 }, | |
9175 set host(host) { | |
9176 if (this._isInvalid || !this._isRelative) | |
9177 return; | |
9178 parse.call(this, host, 'host'); | |
9179 }, | |
9180 | |
9181 get hostname() { | |
9182 return this._host; | |
9183 }, | |
9184 set hostname(hostname) { | |
9185 if (this._isInvalid || !this._isRelative) | |
9186 return; | |
9187 parse.call(this, hostname, 'hostname'); | |
9188 }, | |
9189 | |
9190 get port() { | |
9191 return this._port; | |
9192 }, | |
9193 set port(port) { | |
9194 if (this._isInvalid || !this._isRelative) | |
9195 return; | |
9196 parse.call(this, port, 'port'); | |
9197 }, | |
9198 | |
9199 get pathname() { | |
9200 return this._isInvalid ? '' : this._isRelative ? | |
9201 '/' + this._path.join('/') : this._schemeData; | |
9202 }, | |
9203 set pathname(pathname) { | |
9204 if (this._isInvalid || !this._isRelative) | |
9205 return; | |
9206 this._path = []; | |
9207 parse.call(this, pathname, 'relative path start'); | |
9208 }, | |
9209 | |
9210 get search() { | |
9211 return this._isInvalid || !this._query || '?' == this._query ? | |
9212 '' : this._query; | |
9213 }, | |
9214 set search(search) { | |
9215 if (this._isInvalid || !this._isRelative) | |
9216 return; | |
9217 this._query = '?'; | |
9218 if ('?' == search[0]) | |
9219 search = search.slice(1); | |
9220 parse.call(this, search, 'query'); | |
9221 }, | |
9222 | |
9223 get hash() { | |
9224 return this._isInvalid || !this._fragment || '#' == this._fragment ? | |
9225 '' : this._fragment; | |
9226 }, | |
9227 set hash(hash) { | |
9228 if (this._isInvalid) | |
9229 return; | |
9230 this._fragment = '#'; | |
9231 if ('#' == hash[0]) | |
9232 hash = hash.slice(1); | |
9233 parse.call(this, hash, 'fragment'); | |
9234 } | |
9235 }; | |
9236 | |
9237 scope.URL = jURL; | |
9238 | |
9239 })(window); | |
9240 | |
9241 /* | 8874 /* |
9242 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. | 8875 * 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 | 8876 * 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 | 8877 * 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 | 8878 * 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 | 8879 * 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 | 8880 * subject to an additional IP rights grant found at http://polymer.github.io/PA
TENTS.txt |
9248 */ | 8881 */ |
9249 | 8882 |
9250 (function(scope) { | 8883 (function(scope) { |
(...skipping 1533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10784 }, | 10417 }, |
10785 parseStyle: function(elt) { | 10418 parseStyle: function(elt) { |
10786 // TODO(sorvell): style element load event can just not fire so clone styles | 10419 // TODO(sorvell): style element load event can just not fire so clone styles |
10787 var src = elt; | 10420 var src = elt; |
10788 elt = cloneStyle(elt); | 10421 elt = cloneStyle(elt); |
10789 elt.__importElement = src; | 10422 elt.__importElement = src; |
10790 this.parseGeneric(elt); | 10423 this.parseGeneric(elt); |
10791 }, | 10424 }, |
10792 parseGeneric: function(elt) { | 10425 parseGeneric: function(elt) { |
10793 this.trackElement(elt); | 10426 this.trackElement(elt); |
10794 document.head.appendChild(elt); | 10427 this.addElementToDocument(elt); |
| 10428 }, |
| 10429 rootImportForElement: function(elt) { |
| 10430 var n = elt; |
| 10431 while (n.ownerDocument.__importLink) { |
| 10432 n = n.ownerDocument.__importLink; |
| 10433 } |
| 10434 return n; |
| 10435 }, |
| 10436 addElementToDocument: function(elt) { |
| 10437 var port = this.rootImportForElement(elt.__importElement || elt); |
| 10438 var l = port.__insertedElements = port.__insertedElements || 0; |
| 10439 var refNode = port.nextElementSibling; |
| 10440 for (var i=0; i < l; i++) { |
| 10441 refNode = refNode && refNode.nextElementSibling; |
| 10442 } |
| 10443 port.parentNode.insertBefore(elt, refNode); |
10795 }, | 10444 }, |
10796 // tracks when a loadable element has loaded | 10445 // tracks when a loadable element has loaded |
10797 trackElement: function(elt, callback) { | 10446 trackElement: function(elt, callback) { |
10798 var self = this; | 10447 var self = this; |
10799 var done = function(e) { | 10448 var done = function(e) { |
10800 if (callback) { | 10449 if (callback) { |
10801 callback(e); | 10450 callback(e); |
10802 } | 10451 } |
10803 self.markParsingComplete(elt); | 10452 self.markParsingComplete(elt); |
10804 self.parseNext(); | 10453 self.parseNext(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10841 parseScript: function(scriptElt) { | 10490 parseScript: function(scriptElt) { |
10842 var script = document.createElement('script'); | 10491 var script = document.createElement('script'); |
10843 script.__importElement = scriptElt; | 10492 script.__importElement = scriptElt; |
10844 script.src = scriptElt.src ? scriptElt.src : | 10493 script.src = scriptElt.src ? scriptElt.src : |
10845 generateScriptDataUrl(scriptElt); | 10494 generateScriptDataUrl(scriptElt); |
10846 scope.currentScript = scriptElt; | 10495 scope.currentScript = scriptElt; |
10847 this.trackElement(script, function(e) { | 10496 this.trackElement(script, function(e) { |
10848 script.parentNode.removeChild(script); | 10497 script.parentNode.removeChild(script); |
10849 scope.currentScript = null; | 10498 scope.currentScript = null; |
10850 }); | 10499 }); |
10851 document.head.appendChild(script); | 10500 this.addElementToDocument(script); |
10852 }, | 10501 }, |
10853 // determine the next element in the tree which should be parsed | 10502 // determine the next element in the tree which should be parsed |
10854 nextToParse: function() { | 10503 nextToParse: function() { |
10855 return !this.parsingElement && this.nextToParseInDoc(mainDoc); | 10504 return !this.parsingElement && this.nextToParseInDoc(mainDoc); |
10856 }, | 10505 }, |
10857 nextToParseInDoc: function(doc, link) { | 10506 nextToParseInDoc: function(doc, link) { |
10858 var nodes = doc.querySelectorAll(this.parseSelectorsForNode(doc)); | 10507 var nodes = doc.querySelectorAll(this.parseSelectorsForNode(doc)); |
10859 for (var i=0, l=nodes.length, p=0, n; (i<l) && (n=nodes[i]); i++) { | 10508 for (var i=0, l=nodes.length, p=0, n; (i<l) && (n=nodes[i]); i++) { |
10860 if (!this.isParsed(n)) { | 10509 if (!this.isParsed(n)) { |
10861 if (this.hasResource(n)) { | 10510 if (this.hasResource(n)) { |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11387 (document.readyState === 'interactive' && !window.attachEvent)) { | 11036 (document.readyState === 'interactive' && !window.attachEvent)) { |
11388 bootstrap(); | 11037 bootstrap(); |
11389 } else { | 11038 } else { |
11390 document.addEventListener('DOMContentLoaded', bootstrap); | 11039 document.addEventListener('DOMContentLoaded', bootstrap); |
11391 } | 11040 } |
11392 } | 11041 } |
11393 | 11042 |
11394 })(); | 11043 })(); |
11395 | 11044 |
11396 /* | 11045 /* |
11397 * Copyright 2013 The Polymer Authors. All rights reserved. | 11046 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
11398 * Use of this source code is governed by a BSD-style | 11047 * 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. | 11048 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.
txt |
| 11049 * The complete set of contributors may be found at http://polymer.github.io/CON
TRIBUTORS.txt |
| 11050 * Code distributed by Google as part of the polymer project is also |
| 11051 * subject to an additional IP rights grant found at http://polymer.github.io/PA
TENTS.txt |
11400 */ | 11052 */ |
11401 window.CustomElements = window.CustomElements || {flags:{}}; | 11053 window.CustomElements = window.CustomElements || {flags:{}}; |
11402 /* | 11054 /* |
11403 Copyright 2013 The Polymer Authors. All rights reserved. | 11055 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
11404 Use of this source code is governed by a BSD-style | 11056 * 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. | 11057 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.
txt |
11406 */ | 11058 * The complete set of contributors may be found at http://polymer.github.io/CON
TRIBUTORS.txt |
| 11059 * Code distributed by Google as part of the polymer project is also |
| 11060 * subject to an additional IP rights grant found at http://polymer.github.io/PA
TENTS.txt |
| 11061 */ |
11407 | 11062 |
11408 (function(scope){ | 11063 (function(scope){ |
11409 | 11064 |
11410 var logFlags = window.logFlags || {}; | 11065 var logFlags = window.logFlags || {}; |
11411 var IMPORT_LINK_TYPE = window.HTMLImports ? HTMLImports.IMPORT_LINK_TYPE : 'none
'; | 11066 var IMPORT_LINK_TYPE = window.HTMLImports ? HTMLImports.IMPORT_LINK_TYPE : 'none
'; |
11412 | 11067 |
11413 // walk the subtree rooted at node, applying 'find(element, data)' function | 11068 // walk the subtree rooted at node, applying 'find(element, data)' function |
11414 // to each element | 11069 // to each element |
11415 // if 'find' returns true for 'element', do not search element's subtree | 11070 // if 'find' returns true for 'element', do not search element's subtree |
11416 function findAll(node, find, data) { | 11071 function findAll(node, find, data) { |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11738 scope.insertedNode = insertedNode; | 11393 scope.insertedNode = insertedNode; |
11739 | 11394 |
11740 scope.observeDocument = observeDocument; | 11395 scope.observeDocument = observeDocument; |
11741 scope.upgradeDocument = upgradeDocument; | 11396 scope.upgradeDocument = upgradeDocument; |
11742 | 11397 |
11743 scope.takeRecords = takeRecords; | 11398 scope.takeRecords = takeRecords; |
11744 | 11399 |
11745 })(window.CustomElements); | 11400 })(window.CustomElements); |
11746 | 11401 |
11747 /* | 11402 /* |
11748 * Copyright 2013 The Polymer Authors. All rights reserved. | 11403 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
11749 * Use of this source code is governed by a BSD-style | 11404 * 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. | 11405 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.
txt |
| 11406 * The complete set of contributors may be found at http://polymer.github.io/CON
TRIBUTORS.txt |
| 11407 * Code distributed by Google as part of the polymer project is also |
| 11408 * subject to an additional IP rights grant found at http://polymer.github.io/PA
TENTS.txt |
11751 */ | 11409 */ |
11752 | 11410 |
11753 /** | 11411 /** |
11754 * Implements `document.register` | 11412 * Implements `document.registerElement` |
11755 * @module CustomElements | 11413 * @module CustomElements |
11756 */ | 11414 */ |
11757 | 11415 |
11758 /** | 11416 /** |
11759 * Polyfilled extensions to the `document` object. | 11417 * Polyfilled extensions to the `document` object. |
11760 * @class Document | 11418 * @class Document |
11761 */ | 11419 */ |
11762 | 11420 |
11763 (function(scope) { | 11421 (function(scope) { |
11764 | 11422 |
(...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. | 11634 // output is a valid DOM element with the proper wrapper in place. |
11977 // | 11635 // |
11978 return upgrade(domCreateElement(definition.tag), definition); | 11636 return upgrade(domCreateElement(definition.tag), definition); |
11979 } | 11637 } |
11980 | 11638 |
11981 function upgrade(element, definition) { | 11639 function upgrade(element, definition) { |
11982 // some definitions specify an 'is' attribute | 11640 // some definitions specify an 'is' attribute |
11983 if (definition.is) { | 11641 if (definition.is) { |
11984 element.setAttribute('is', definition.is); | 11642 element.setAttribute('is', definition.is); |
11985 } | 11643 } |
11986 // remove 'unresolved' attr, which is a standin for :unresolved. | |
11987 element.removeAttribute('unresolved'); | |
11988 // make 'element' implement definition.prototype | 11644 // make 'element' implement definition.prototype |
11989 implement(element, definition); | 11645 implement(element, definition); |
11990 // flag as upgraded | 11646 // flag as upgraded |
11991 element.__upgraded__ = true; | 11647 element.__upgraded__ = true; |
11992 // lifecycle management | 11648 // lifecycle management |
11993 created(element); | 11649 created(element); |
11994 // attachedCallback fires in tree order, call before recursing | 11650 // attachedCallback fires in tree order, call before recursing |
11995 scope.insertedNode(element); | 11651 scope.insertedNode(element); |
11996 // there should never be a shadow root on element at this point | 11652 // there should never be a shadow root on element at this point |
11997 scope.upgradeSubtree(element); | 11653 scope.upgradeSubtree(element); |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12215 | 11871 |
12216 // bc | 11872 // bc |
12217 document.register = document.registerElement; | 11873 document.register = document.registerElement; |
12218 | 11874 |
12219 scope.hasNative = hasNative; | 11875 scope.hasNative = hasNative; |
12220 scope.useNative = useNative; | 11876 scope.useNative = useNative; |
12221 | 11877 |
12222 })(window.CustomElements); | 11878 })(window.CustomElements); |
12223 | 11879 |
12224 /* | 11880 /* |
12225 * Copyright 2013 The Polymer Authors. All rights reserved. | 11881 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
12226 * Use of this source code is governed by a BSD-style | 11882 * 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. | 11883 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.
txt |
| 11884 * The complete set of contributors may be found at http://polymer.github.io/CON
TRIBUTORS.txt |
| 11885 * Code distributed by Google as part of the polymer project is also |
| 11886 * subject to an additional IP rights grant found at http://polymer.github.io/PA
TENTS.txt |
12228 */ | 11887 */ |
12229 | 11888 |
12230 (function(scope) { | 11889 (function(scope) { |
12231 | 11890 |
12232 // import | 11891 // import |
12233 | 11892 |
12234 var IMPORT_LINK_TYPE = scope.IMPORT_LINK_TYPE; | 11893 var IMPORT_LINK_TYPE = scope.IMPORT_LINK_TYPE; |
12235 | 11894 |
12236 // highlander object for parsing a document tree | 11895 // highlander object for parsing a document tree |
12237 | 11896 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12279 | 11938 |
12280 var forEach = Array.prototype.forEach.call.bind(Array.prototype.forEach); | 11939 var forEach = Array.prototype.forEach.call.bind(Array.prototype.forEach); |
12281 | 11940 |
12282 // exports | 11941 // exports |
12283 | 11942 |
12284 scope.parser = parser; | 11943 scope.parser = parser; |
12285 scope.IMPORT_LINK_TYPE = IMPORT_LINK_TYPE; | 11944 scope.IMPORT_LINK_TYPE = IMPORT_LINK_TYPE; |
12286 | 11945 |
12287 })(window.CustomElements); | 11946 })(window.CustomElements); |
12288 /* | 11947 /* |
12289 * Copyright 2013 The Polymer Authors. All rights reserved. | 11948 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
12290 * Use of this source code is governed by a BSD-style | 11949 * 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. | 11950 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.
txt |
| 11951 * The complete set of contributors may be found at http://polymer.github.io/CON
TRIBUTORS.txt |
| 11952 * Code distributed by Google as part of the polymer project is also |
| 11953 * subject to an additional IP rights grant found at http://polymer.github.io/PA
TENTS.txt |
12292 */ | 11954 */ |
12293 (function(scope){ | 11955 (function(scope){ |
12294 | 11956 |
12295 // bootstrap parsing | 11957 // bootstrap parsing |
12296 function bootstrap() { | 11958 function bootstrap() { |
12297 // parse document | 11959 // parse document |
12298 CustomElements.parser.parse(document); | 11960 CustomElements.parser.parse(document); |
12299 // one more pass before register is 'live' | 11961 // one more pass before register is 'live' |
12300 CustomElements.upgradeDocument(document); | 11962 CustomElements.upgradeDocument(document); |
12301 // choose async | 11963 // choose async |
(...skipping 18 matching lines...) Expand all Loading... |
12320 if (window.HTMLImports) { | 11982 if (window.HTMLImports) { |
12321 HTMLImports.__importsParsingHook = function(elt) { | 11983 HTMLImports.__importsParsingHook = function(elt) { |
12322 CustomElements.parser.parse(elt.import); | 11984 CustomElements.parser.parse(elt.import); |
12323 } | 11985 } |
12324 } | 11986 } |
12325 }); | 11987 }); |
12326 } | 11988 } |
12327 | 11989 |
12328 // CustomEvent shim for IE | 11990 // CustomEvent shim for IE |
12329 if (typeof window.CustomEvent !== 'function') { | 11991 if (typeof window.CustomEvent !== 'function') { |
12330 window.CustomEvent = function(inType) { | 11992 window.CustomEvent = function(inType, params) { |
12331 var e = document.createEvent('HTMLEvents'); | 11993 params = params || {}; |
12332 e.initEvent(inType, true, true); | 11994 var e = document.createEvent('CustomEvent'); |
| 11995 e.initCustomEvent(inType, Boolean(params.bubbles), Boolean(params.cancelable
), params.detail); |
12333 return e; | 11996 return e; |
12334 }; | 11997 }; |
| 11998 window.CustomEvent.prototype = window.Event.prototype; |
12335 } | 11999 } |
12336 | 12000 |
12337 // When loading at readyState complete time (or via flag), boot custom elements | 12001 // When loading at readyState complete time (or via flag), boot custom elements |
12338 // immediately. | 12002 // immediately. |
12339 // If relevant, HTMLImports must already be loaded. | 12003 // If relevant, HTMLImports must already be loaded. |
12340 if (document.readyState === 'complete' || scope.flags.eager) { | 12004 if (document.readyState === 'complete' || scope.flags.eager) { |
12341 bootstrap(); | 12005 bootstrap(); |
12342 // When loading at readyState interactive time, bootstrap only if HTMLImports | 12006 // 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. | 12007 // are not pending. Also avoid IE as the semantics of this state are unreliable. |
12344 } else if (document.readyState === 'interactive' && !window.attachEvent && | 12008 } else if (document.readyState === 'interactive' && !window.attachEvent && |
(...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13489 get bindingDelegate() { | 13153 get bindingDelegate() { |
13490 return this.delegate_ && this.delegate_.raw; | 13154 return this.delegate_ && this.delegate_.raw; |
13491 }, | 13155 }, |
13492 | 13156 |
13493 refChanged_: function() { | 13157 refChanged_: function() { |
13494 if (!this.iterator_ || this.refContent_ === this.ref_.content) | 13158 if (!this.iterator_ || this.refContent_ === this.ref_.content) |
13495 return; | 13159 return; |
13496 | 13160 |
13497 this.refContent_ = undefined; | 13161 this.refContent_ = undefined; |
13498 this.iterator_.valueChanged(); | 13162 this.iterator_.valueChanged(); |
13499 this.iterator_.updateIteratedValue(); | 13163 this.iterator_.updateIteratedValue(this.iterator_.getUpdatedValue()); |
13500 }, | 13164 }, |
13501 | 13165 |
13502 clear: function() { | 13166 clear: function() { |
13503 this.model_ = undefined; | 13167 this.model_ = undefined; |
13504 this.delegate_ = undefined; | 13168 this.delegate_ = undefined; |
13505 if (this.bindings_ && this.bindings_.ref) | 13169 if (this.bindings_ && this.bindings_.ref) |
13506 this.bindings_.ref.close() | 13170 this.bindings_.ref.close() |
13507 this.refContent_ = undefined; | 13171 this.refContent_ = undefined; |
13508 if (!this.iterator_) | 13172 if (!this.iterator_) |
13509 return; | 13173 return; |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13893 deps.value.close(); | 13557 deps.value.close(); |
13894 } | 13558 } |
13895 }, | 13559 }, |
13896 | 13560 |
13897 updateDependencies: function(directives, model) { | 13561 updateDependencies: function(directives, model) { |
13898 this.closeDeps(); | 13562 this.closeDeps(); |
13899 | 13563 |
13900 var deps = this.deps = {}; | 13564 var deps = this.deps = {}; |
13901 var template = this.templateElement_; | 13565 var template = this.templateElement_; |
13902 | 13566 |
| 13567 var ifValue = true; |
13903 if (directives.if) { | 13568 if (directives.if) { |
13904 deps.hasIf = true; | 13569 deps.hasIf = true; |
13905 deps.ifOneTime = directives.if.onlyOneTime; | 13570 deps.ifOneTime = directives.if.onlyOneTime; |
13906 deps.ifValue = processBinding(IF, directives.if, template, model); | 13571 deps.ifValue = processBinding(IF, directives.if, template, model); |
13907 | 13572 |
| 13573 ifValue = deps.ifValue; |
| 13574 |
13908 // oneTime if & predicate is false. nothing else to do. | 13575 // oneTime if & predicate is false. nothing else to do. |
13909 if (deps.ifOneTime && !deps.ifValue) { | 13576 if (deps.ifOneTime && !ifValue) { |
13910 this.updateIteratedValue(); | 13577 this.valueChanged(); |
13911 return; | 13578 return; |
13912 } | 13579 } |
13913 | 13580 |
13914 if (!deps.ifOneTime) | 13581 if (!deps.ifOneTime) |
13915 deps.ifValue.open(this.updateIteratedValue, this); | 13582 ifValue = ifValue.open(this.updateIfValue, this); |
13916 } | 13583 } |
13917 | 13584 |
13918 if (directives.repeat) { | 13585 if (directives.repeat) { |
13919 deps.repeat = true; | 13586 deps.repeat = true; |
13920 deps.oneTime = directives.repeat.onlyOneTime; | 13587 deps.oneTime = directives.repeat.onlyOneTime; |
13921 deps.value = processBinding(REPEAT, directives.repeat, template, model); | 13588 deps.value = processBinding(REPEAT, directives.repeat, template, model); |
13922 } else { | 13589 } else { |
13923 deps.repeat = false; | 13590 deps.repeat = false; |
13924 deps.oneTime = directives.bind.onlyOneTime; | 13591 deps.oneTime = directives.bind.onlyOneTime; |
13925 deps.value = processBinding(BIND, directives.bind, template, model); | 13592 deps.value = processBinding(BIND, directives.bind, template, model); |
13926 } | 13593 } |
13927 | 13594 |
| 13595 var value = deps.value; |
13928 if (!deps.oneTime) | 13596 if (!deps.oneTime) |
13929 deps.value.open(this.updateIteratedValue, this); | 13597 value = value.open(this.updateIteratedValue, this); |
13930 | 13598 |
13931 this.updateIteratedValue(); | 13599 if (!ifValue) { |
| 13600 this.valueChanged(); |
| 13601 return; |
| 13602 } |
| 13603 |
| 13604 this.updateValue(value); |
13932 }, | 13605 }, |
13933 | 13606 |
13934 updateIteratedValue: function() { | 13607 /** |
| 13608 * Gets the updated value of the bind/repeat. This can potentially call |
| 13609 * user code (if a bindingDelegate is set up) so we try to avoid it if we |
| 13610 * already have the value in hand (from Observer.open). |
| 13611 */ |
| 13612 getUpdatedValue: function() { |
| 13613 var value = this.deps.value; |
| 13614 if (!this.deps.oneTime) |
| 13615 value = value.discardChanges(); |
| 13616 return value; |
| 13617 }, |
| 13618 |
| 13619 updateIfValue: function(ifValue) { |
| 13620 if (!ifValue) { |
| 13621 this.valueChanged(); |
| 13622 return; |
| 13623 } |
| 13624 |
| 13625 this.updateValue(this.getUpdatedValue()); |
| 13626 }, |
| 13627 |
| 13628 updateIteratedValue: function(value) { |
13935 if (this.deps.hasIf) { | 13629 if (this.deps.hasIf) { |
13936 var ifValue = this.deps.ifValue; | 13630 var ifValue = this.deps.ifValue; |
13937 if (!this.deps.ifOneTime) | 13631 if (!this.deps.ifOneTime) |
13938 ifValue = ifValue.discardChanges(); | 13632 ifValue = ifValue.discardChanges(); |
13939 if (!ifValue) { | 13633 if (!ifValue) { |
13940 this.valueChanged(); | 13634 this.valueChanged(); |
13941 return; | 13635 return; |
13942 } | 13636 } |
13943 } | 13637 } |
13944 | 13638 |
13945 var value = this.deps.value; | 13639 this.updateValue(value); |
13946 if (!this.deps.oneTime) | 13640 }, |
13947 value = value.discardChanges(); | 13641 |
| 13642 updateValue: function(value) { |
13948 if (!this.deps.repeat) | 13643 if (!this.deps.repeat) |
13949 value = [value]; | 13644 value = [value]; |
13950 var observe = this.deps.repeat && | 13645 var observe = this.deps.repeat && |
13951 !this.deps.oneTime && | 13646 !this.deps.oneTime && |
13952 Array.isArray(value); | 13647 Array.isArray(value); |
13953 this.valueChanged(value, observe); | 13648 this.valueChanged(value, observe); |
13954 }, | 13649 }, |
13955 | 13650 |
13956 valueChanged: function(value, observeValue) { | 13651 valueChanged: function(value, observeValue) { |
13957 if (!Array.isArray(value)) | 13652 if (!Array.isArray(value)) |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14228 } | 13923 } |
14229 } | 13924 } |
14230 | 13925 |
14231 // exports | 13926 // exports |
14232 scope.flush = flush; | 13927 scope.flush = flush; |
14233 | 13928 |
14234 })(window.Platform); | 13929 })(window.Platform); |
14235 | 13930 |
14236 | 13931 |
14237 //# sourceMappingURL=platform.concat.js.map | 13932 //# sourceMappingURL=platform.concat.js.map |
OLD | NEW |