Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Side by Side Diff: pkg/web_components/lib/platform.concat.js

Issue 482763002: Revert "Roll polymer to 0.3.5" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/web_components/lib/platform.js ('k') | pkg/web_components/lib/platform.concat.js.map » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 var entry = key[this.name]; 98 this.set(key, undefined);
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;
108 } 99 }
109 }; 100 };
110 101
111 window.WeakMap = WeakMap; 102 window.WeakMap = WeakMap;
112 })(); 103 })();
113 } 104 }
114 105
115 // Copyright 2012 Google Inc. 106 // Copyright 2012 Google Inc.
116 // 107 //
117 // Licensed under the Apache License, Version 2.0 (the "License"); 108 // Licensed under the Apache License, Version 2.0 (the "License");
118 // you may not use this file except in compliance with the License. 109 // you may not use this file except in compliance with the License.
119 // You may obtain a copy of the License at 110 // You may obtain a copy of the License at
120 // 111 //
121 // http://www.apache.org/licenses/LICENSE-2.0 112 // http://www.apache.org/licenses/LICENSE-2.0
122 // 113 //
123 // Unless required by applicable law or agreed to in writing, software 114 // Unless required by applicable law or agreed to in writing, software
124 // distributed under the License is distributed on an "AS IS" BASIS, 115 // distributed under the License is distributed on an "AS IS" BASIS,
125 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 116 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
126 // See the License for the specific language governing permissions and 117 // See the License for the specific language governing permissions and
127 // limitations under the License. 118 // limitations under the License.
128 119
129 (function(global) { 120 (function(global) {
130 'use strict'; 121 'use strict';
131 122
132 var testingExposeCycleCount = global.testingExposeCycleCount;
133
134 // Detect and do basic sanity checking on Object/Array.observe. 123 // Detect and do basic sanity checking on Object/Array.observe.
135 function detectObjectObserve() { 124 function detectObjectObserve() {
136 if (typeof Object.observe !== 'function' || 125 if (typeof Object.observe !== 'function' ||
137 typeof Array.observe !== 'function') { 126 typeof Array.observe !== 'function') {
138 return false; 127 return false;
139 } 128 }
140 129
141 var records = []; 130 var records = [];
142 131
143 function callback(recs) { 132 function callback(recs) {
(...skipping 30 matching lines...) Expand all
174 163
175 var hasObserve = detectObjectObserve(); 164 var hasObserve = detectObjectObserve();
176 165
177 function detectEval() { 166 function detectEval() {
178 // Don't test for eval if we're running in a Chrome App environment. 167 // Don't test for eval if we're running in a Chrome App environment.
179 // We check for APIs set that only exist in a Chrome App context. 168 // We check for APIs set that only exist in a Chrome App context.
180 if (typeof chrome !== 'undefined' && chrome.app && chrome.app.runtime) { 169 if (typeof chrome !== 'undefined' && chrome.app && chrome.app.runtime) {
181 return false; 170 return false;
182 } 171 }
183 172
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
191 try { 173 try {
192 var f = new Function('', 'return true;'); 174 var f = new Function('', 'return true;');
193 return f(); 175 return f();
194 } catch (ex) { 176 } catch (ex) {
195 return false; 177 return false;
196 } 178 }
197 } 179 }
198 180
199 var hasEval = detectEval(); 181 var hasEval = detectEval();
200 182
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 invalidPath.valid = false; 537 invalidPath.valid = false;
556 invalidPath.getValueFrom = invalidPath.setValueFrom = function() {}; 538 invalidPath.getValueFrom = invalidPath.setValueFrom = function() {};
557 539
558 var MAX_DIRTY_CHECK_CYCLES = 1000; 540 var MAX_DIRTY_CHECK_CYCLES = 1000;
559 541
560 function dirtyCheck(observer) { 542 function dirtyCheck(observer) {
561 var cycles = 0; 543 var cycles = 0;
562 while (cycles < MAX_DIRTY_CHECK_CYCLES && observer.check_()) { 544 while (cycles < MAX_DIRTY_CHECK_CYCLES && observer.check_()) {
563 cycles++; 545 cycles++;
564 } 546 }
565 if (testingExposeCycleCount) 547 if (global.testingExposeCycleCount)
566 global.dirtyCheckCycleCount = cycles; 548 global.dirtyCheckCycleCount = cycles;
567 549
568 return cycles > 0; 550 return cycles > 0;
569 } 551 }
570 552
571 function objectIsEmpty(object) { 553 function objectIsEmpty(object) {
572 for (var prop in object) 554 for (var prop in object)
573 return false; 555 return false;
574 return true; 556 return true;
575 } 557 }
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 936
955 if (observer.check_()) 937 if (observer.check_())
956 anyChanged = true; 938 anyChanged = true;
957 939
958 allObservers.push(observer); 940 allObservers.push(observer);
959 } 941 }
960 if (runEOMTasks()) 942 if (runEOMTasks())
961 anyChanged = true; 943 anyChanged = true;
962 } while (cycles < MAX_DIRTY_CHECK_CYCLES && anyChanged); 944 } while (cycles < MAX_DIRTY_CHECK_CYCLES && anyChanged);
963 945
964 if (testingExposeCycleCount) 946 if (global.testingExposeCycleCount)
965 global.dirtyCheckCycleCount = cycles; 947 global.dirtyCheckCycleCount = cycles;
966 948
967 runningMicrotaskCheckpoint = false; 949 runningMicrotaskCheckpoint = false;
968 }; 950 };
969 951
970 if (collectObservers) { 952 if (collectObservers) {
971 global.Platform.clearObservers = function() { 953 global.Platform.clearObservers = function() {
972 allObservers = []; 954 allObservers = [];
973 }; 955 };
974 } 956 }
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after
1856 var nativePrototypeTable = new WeakMap(); 1838 var nativePrototypeTable = new WeakMap();
1857 var wrappers = Object.create(null); 1839 var wrappers = Object.create(null);
1858 1840
1859 function detectEval() { 1841 function detectEval() {
1860 // Don't test for eval if we're running in a Chrome App environment. 1842 // Don't test for eval if we're running in a Chrome App environment.
1861 // We check for APIs set that only exist in a Chrome App context. 1843 // We check for APIs set that only exist in a Chrome App context.
1862 if (typeof chrome !== 'undefined' && chrome.app && chrome.app.runtime) { 1844 if (typeof chrome !== 'undefined' && chrome.app && chrome.app.runtime) {
1863 return false; 1845 return false;
1864 } 1846 }
1865 1847
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
1873 try { 1848 try {
1874 var f = new Function('return true;'); 1849 var f = new Function('return true;');
1875 return f(); 1850 return f();
1876 } catch (ex) { 1851 } catch (ex) {
1877 return false; 1852 return false;
1878 } 1853 }
1879 } 1854 }
1880 1855
1881 var hasEval = detectEval(); 1856 var hasEval = detectEval();
1882 1857
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
2120 2095
2121 var OriginalDOMImplementation = window.DOMImplementation; 2096 var OriginalDOMImplementation = window.DOMImplementation;
2122 var OriginalEventTarget = window.EventTarget; 2097 var OriginalEventTarget = window.EventTarget;
2123 var OriginalEvent = window.Event; 2098 var OriginalEvent = window.Event;
2124 var OriginalNode = window.Node; 2099 var OriginalNode = window.Node;
2125 var OriginalWindow = window.Window; 2100 var OriginalWindow = window.Window;
2126 var OriginalRange = window.Range; 2101 var OriginalRange = window.Range;
2127 var OriginalCanvasRenderingContext2D = window.CanvasRenderingContext2D; 2102 var OriginalCanvasRenderingContext2D = window.CanvasRenderingContext2D;
2128 var OriginalWebGLRenderingContext = window.WebGLRenderingContext; 2103 var OriginalWebGLRenderingContext = window.WebGLRenderingContext;
2129 var OriginalSVGElementInstance = window.SVGElementInstance; 2104 var OriginalSVGElementInstance = window.SVGElementInstance;
2130 var OriginalFormData = window.FormData; 2105
2131
2132 function isWrapper(object) { 2106 function isWrapper(object) {
2133 return object instanceof wrappers.EventTarget || 2107 return object instanceof wrappers.EventTarget ||
2134 object instanceof wrappers.Event || 2108 object instanceof wrappers.Event ||
2135 object instanceof wrappers.Range || 2109 object instanceof wrappers.Range ||
2136 object instanceof wrappers.DOMImplementation || 2110 object instanceof wrappers.DOMImplementation ||
2137 object instanceof wrappers.CanvasRenderingContext2D || 2111 object instanceof wrappers.CanvasRenderingContext2D ||
2138 object instanceof wrappers.FormData ||
2139 wrappers.WebGLRenderingContext && 2112 wrappers.WebGLRenderingContext &&
2140 object instanceof wrappers.WebGLRenderingContext; 2113 object instanceof wrappers.WebGLRenderingContext;
2141 } 2114 }
2142 2115
2143 function isNative(object) { 2116 function isNative(object) {
2144 return OriginalEventTarget && object instanceof OriginalEventTarget || 2117 return OriginalEventTarget && object instanceof OriginalEventTarget ||
2145 object instanceof OriginalNode || 2118 object instanceof OriginalNode ||
2146 object instanceof OriginalEvent || 2119 object instanceof OriginalEvent ||
2147 object instanceof OriginalWindow || 2120 object instanceof OriginalWindow ||
2148 object instanceof OriginalRange || 2121 object instanceof OriginalRange ||
2149 object instanceof OriginalDOMImplementation || 2122 object instanceof OriginalDOMImplementation ||
2150 object instanceof OriginalCanvasRenderingContext2D || 2123 object instanceof OriginalCanvasRenderingContext2D ||
2151 object instanceof OriginalFormData ||
2152 OriginalWebGLRenderingContext && 2124 OriginalWebGLRenderingContext &&
2153 object instanceof OriginalWebGLRenderingContext || 2125 object instanceof OriginalWebGLRenderingContext ||
2154 OriginalSVGElementInstance && 2126 OriginalSVGElementInstance &&
2155 object instanceof OriginalSVGElementInstance; 2127 object instanceof OriginalSVGElementInstance;
2156 } 2128 }
2157 2129
2158 /** 2130 /**
2159 * Wraps a node in a WrapperNode. If there already exists a wrapper for the 2131 * Wraps a node in a WrapperNode. If there already exists a wrapper for the
2160 * |node| that wrapper is returned instead. 2132 * |node| that wrapper is returned instead.
2161 * @param {Node} node 2133 * @param {Node} node
(...skipping 2443 matching lines...) Expand 10 before | Expand all | Expand 10 after
4605 4577
4606 // Copyright 2013 The Polymer Authors. All rights reserved. 4578 // Copyright 2013 The Polymer Authors. All rights reserved.
4607 // Use of this source code is governed by a BSD-style 4579 // Use of this source code is governed by a BSD-style
4608 // license that can be found in the LICENSE file. 4580 // license that can be found in the LICENSE file.
4609 4581
4610 (function(scope) { 4582 (function(scope) {
4611 'use strict'; 4583 'use strict';
4612 4584
4613 var HTMLCollection = scope.wrappers.HTMLCollection; 4585 var HTMLCollection = scope.wrappers.HTMLCollection;
4614 var NodeList = scope.wrappers.NodeList; 4586 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 }
4648 4587
4649 function findOne(node, selector) { 4588 function findOne(node, selector) {
4650 var m, el = node.firstElementChild; 4589 var m, el = node.firstElementChild;
4651 while (el) { 4590 while (el) {
4652 if (el.matches(selector)) 4591 if (el.matches(selector))
4653 return el; 4592 return el;
4654 m = findOne(el, selector); 4593 m = findOne(el, selector);
4655 if (m) 4594 if (m)
4656 return m; 4595 return m;
4657 el = el.nextElementSibling; 4596 el = el.nextElementSibling;
(...skipping 10 matching lines...) Expand all
4668 function matchesTagName(el, localName, localNameLowerCase) { 4607 function matchesTagName(el, localName, localNameLowerCase) {
4669 var ln = el.localName; 4608 var ln = el.localName;
4670 return ln === localName || 4609 return ln === localName ||
4671 ln === localNameLowerCase && el.namespaceURI === XHTML_NS; 4610 ln === localNameLowerCase && el.namespaceURI === XHTML_NS;
4672 } 4611 }
4673 4612
4674 function matchesEveryThing() { 4613 function matchesEveryThing() {
4675 return true; 4614 return true;
4676 } 4615 }
4677 4616
4678 function matchesLocalNameOnly(el, ns, localName) { 4617 function matchesLocalName(el, localName) {
4679 return el.localName === localName; 4618 return el.localName === localName;
4680 } 4619 }
4681 4620
4682 function matchesNameSpace(el, ns) { 4621 function matchesNameSpace(el, ns) {
4683 return el.namespaceURI === ns; 4622 return el.namespaceURI === ns;
4684 } 4623 }
4685 4624
4686 function matchesLocalNameNS(el, ns, localName) { 4625 function matchesLocalNameNS(el, ns, localName) {
4687 return el.namespaceURI === ns && el.localName === localName; 4626 return el.namespaceURI === ns && el.localName === localName;
4688 } 4627 }
4689 4628
4690 function findElements(node, index, result, p, arg0, arg1) { 4629 function findElements(node, result, p, arg0, arg1) {
4691 var el = node.firstElementChild; 4630 var el = node.firstElementChild;
4692 while (el) { 4631 while (el) {
4693 if (p(el, arg0, arg1)) 4632 if (p(el, arg0, arg1))
4694 result[index++] = el; 4633 result[result.length++] = el;
4695 index = findElements(el, index, result, p, arg0, arg1); 4634 findElements(el, result, p, arg0, arg1);
4696 el = el.nextElementSibling; 4635 el = el.nextElementSibling;
4697 } 4636 }
4698 return index; 4637 return result;
4699 } 4638 }
4700 4639
4701 // find and findAll will only match Simple Selectors, 4640 // find and findAll will only match Simple Selectors,
4702 // Structural Pseudo Classes are not guarenteed to be correct 4641 // Structural Pseudo Classes are not guarenteed to be correct
4703 // http://www.w3.org/TR/css3-selectors/#simple-selectors 4642 // http://www.w3.org/TR/css3-selectors/#simple-selectors
4704 4643
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
4726 var SelectorsInterface = { 4644 var SelectorsInterface = {
4727 querySelector: function(selector) { 4645 querySelector: function(selector) {
4728 var target = this.impl; 4646 return findOne(this, selector);
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;
4758 }, 4647 },
4759 querySelectorAll: function(selector) { 4648 querySelectorAll: function(selector) {
4760 var result = new NodeList(); 4649 return findElements(this, new NodeList(), matchesSelector, selector);
4761
4762 result.length = querySelectorAllFiltered.call(this,
4763 matchesSelector,
4764 0,
4765 result,
4766 selector);
4767
4768 return result;
4769 } 4650 }
4770 }; 4651 };
4771 4652
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
4814 var GetElementsByInterface = { 4653 var GetElementsByInterface = {
4815 getElementsByTagName: function(localName) { 4654 getElementsByTagName: function(localName) {
4816 var result = new HTMLCollection(); 4655 var result = new HTMLCollection();
4817 var match = localName === '*' ? matchesEveryThing : matchesTagName; 4656 if (localName === '*')
4657 return findElements(this, result, matchesEveryThing);
4818 4658
4819 result.length = getElementsByTagNameFiltered.call(this, 4659 return findElements(this, result,
4820 match, 4660 matchesTagName,
4821 0,
4822 result,
4823 localName, 4661 localName,
4824 localName.toLowerCase()); 4662 localName.toLowerCase());
4825
4826 return result;
4827 }, 4663 },
4828 4664
4829 getElementsByClassName: function(className) { 4665 getElementsByClassName: function(className) {
4830 // TODO(arv): Check className? 4666 // TODO(arv): Check className?
4831 return this.querySelectorAll('.' + className); 4667 return this.querySelectorAll('.' + className);
4832 }, 4668 },
4833 4669
4834 getElementsByTagNameNS: function(ns, localName) { 4670 getElementsByTagNameNS: function(ns, localName) {
4835 var result = new HTMLCollection(); 4671 var result = new HTMLCollection();
4836 var match = null;
4837 4672
4838 if (ns === '*') { 4673 if (ns === '') {
4839 match = localName === '*' ? matchesEveryThing : matchesLocalNameOnly; 4674 ns = null;
4840 } else { 4675 } else if (ns === '*') {
4841 match = localName === '*' ? matchesNameSpace : matchesLocalNameNS; 4676 if (localName === '*')
4677 return findElements(this, result, matchesEveryThing);
4678 return findElements(this, result, matchesLocalName, localName);
4842 } 4679 }
4843
4844 result.length = getElementsByTagNameNSFiltered.call(this,
4845 match,
4846 0,
4847 result,
4848 ns || null,
4849 localName);
4850 4680
4851 return result; 4681 if (localName === '*')
4682 return findElements(this, result, matchesNameSpace, ns);
4683
4684 return findElements(this, result, matchesLocalNameNS, ns, localName);
4852 } 4685 }
4853 }; 4686 };
4854 4687
4855 scope.GetElementsByInterface = GetElementsByInterface; 4688 scope.GetElementsByInterface = GetElementsByInterface;
4856 scope.SelectorsInterface = SelectorsInterface; 4689 scope.SelectorsInterface = SelectorsInterface;
4857 4690
4858 })(window.ShadowDOMPolyfill); 4691 })(window.ShadowDOMPolyfill);
4859 4692
4860 // Copyright 2013 The Polymer Authors. All rights reserved. 4693 // Copyright 2013 The Polymer Authors. All rights reserved.
4861 // Use of this source code is goverened by a BSD-style 4694 // Use of this source code is goverened by a BSD-style
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
5445 case 'beforeend': 5278 case 'beforeend':
5446 contextElement = this; 5279 contextElement = this;
5447 refNode = null; 5280 refNode = null;
5448 break; 5281 break;
5449 default: 5282 default:
5450 return; 5283 return;
5451 } 5284 }
5452 5285
5453 var df = frag(contextElement, text); 5286 var df = frag(contextElement, text);
5454 contextElement.insertBefore(df, refNode); 5287 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 }
5466 } 5288 }
5467 }); 5289 });
5468 5290
5469 function frag(contextElement, html) { 5291 function frag(contextElement, html) {
5470 // TODO(arv): This does not work with SVG and other non HTML elements. 5292 // TODO(arv): This does not work with SVG and other non HTML elements.
5471 var p = unwrap(contextElement.cloneNode(false)); 5293 var p = unwrap(contextElement.cloneNode(false));
5472 p.innerHTML = html; 5294 p.innerHTML = html;
5473 var df = unwrap(document.createDocumentFragment()); 5295 var df = unwrap(document.createDocumentFragment());
5474 var c; 5296 var c;
5475 while (c = p.firstChild) { 5297 while (c = p.firstChild) {
(...skipping 2232 matching lines...) Expand 10 before | Expand all | Expand 10 after
7708 var Selection = scope.wrappers.Selection; 7530 var Selection = scope.wrappers.Selection;
7709 var mixin = scope.mixin; 7531 var mixin = scope.mixin;
7710 var registerWrapper = scope.registerWrapper; 7532 var registerWrapper = scope.registerWrapper;
7711 var renderAllPending = scope.renderAllPending; 7533 var renderAllPending = scope.renderAllPending;
7712 var unwrap = scope.unwrap; 7534 var unwrap = scope.unwrap;
7713 var unwrapIfNeeded = scope.unwrapIfNeeded; 7535 var unwrapIfNeeded = scope.unwrapIfNeeded;
7714 var wrap = scope.wrap; 7536 var wrap = scope.wrap;
7715 7537
7716 var OriginalWindow = window.Window; 7538 var OriginalWindow = window.Window;
7717 var originalGetComputedStyle = window.getComputedStyle; 7539 var originalGetComputedStyle = window.getComputedStyle;
7718 var originalGetDefaultComputedStyle = window.getDefaultComputedStyle;
7719 var originalGetSelection = window.getSelection; 7540 var originalGetSelection = window.getSelection;
7720 7541
7721 function Window(impl) { 7542 function Window(impl) {
7722 EventTarget.call(this, impl); 7543 EventTarget.call(this, impl);
7723 } 7544 }
7724 Window.prototype = Object.create(EventTarget.prototype); 7545 Window.prototype = Object.create(EventTarget.prototype);
7725 7546
7726 OriginalWindow.prototype.getComputedStyle = function(el, pseudo) { 7547 OriginalWindow.prototype.getComputedStyle = function(el, pseudo) {
7727 return wrap(this || window).getComputedStyle(unwrapIfNeeded(el), pseudo); 7548 return wrap(this || window).getComputedStyle(unwrapIfNeeded(el), pseudo);
7728 }; 7549 };
7729 7550
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
7738 OriginalWindow.prototype.getSelection = function() { 7551 OriginalWindow.prototype.getSelection = function() {
7739 return wrap(this || window).getSelection(); 7552 return wrap(this || window).getSelection();
7740 }; 7553 };
7741 7554
7742 // Work around for https://bugzilla.mozilla.org/show_bug.cgi?id=943065 7555 // Work around for https://bugzilla.mozilla.org/show_bug.cgi?id=943065
7743 delete window.getComputedStyle; 7556 delete window.getComputedStyle;
7744 delete window.getSelection; 7557 delete window.getSelection;
7745 7558
7746 ['addEventListener', 'removeEventListener', 'dispatchEvent'].forEach( 7559 ['addEventListener', 'removeEventListener', 'dispatchEvent'].forEach(
7747 function(name) { 7560 function(name) {
(...skipping 15 matching lines...) Expand all
7763 getSelection: function() { 7576 getSelection: function() {
7764 renderAllPending(); 7577 renderAllPending();
7765 return new Selection(originalGetSelection.call(unwrap(this))); 7578 return new Selection(originalGetSelection.call(unwrap(this)));
7766 }, 7579 },
7767 7580
7768 get document() { 7581 get document() {
7769 return wrap(unwrap(this).document); 7582 return wrap(unwrap(this).document);
7770 } 7583 }
7771 }); 7584 });
7772 7585
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
7782 registerWrapper(OriginalWindow, Window, window); 7586 registerWrapper(OriginalWindow, Window, window);
7783 7587
7784 scope.wrappers.Window = Window; 7588 scope.wrappers.Window = Window;
7785 7589
7786 })(window.ShadowDOMPolyfill); 7590 })(window.ShadowDOMPolyfill);
7787 7591
7788 /** 7592 /**
7789 * Copyright 2014 The Polymer Authors. All rights reserved. 7593 * Copyright 2014 The Polymer Authors. All rights reserved.
7790 * Use of this source code is goverened by a BSD-style 7594 * Use of this source code is goverened by a BSD-style
7791 * license that can be found in the LICENSE file. 7595 * license that can be found in the LICENSE file.
(...skipping 28 matching lines...) Expand all
7820 7624
7821 (function(scope) { 7625 (function(scope) {
7822 'use strict'; 7626 'use strict';
7823 7627
7824 var registerWrapper = scope.registerWrapper; 7628 var registerWrapper = scope.registerWrapper;
7825 var unwrap = scope.unwrap; 7629 var unwrap = scope.unwrap;
7826 7630
7827 var OriginalFormData = window.FormData; 7631 var OriginalFormData = window.FormData;
7828 7632
7829 function FormData(formElement) { 7633 function FormData(formElement) {
7830 if (formElement instanceof OriginalFormData) 7634 this.impl = new OriginalFormData(formElement && unwrap(formElement));
7831 this.impl = formElement;
7832 else
7833 this.impl = new OriginalFormData(formElement && unwrap(formElement));
7834 } 7635 }
7835 7636
7836 registerWrapper(OriginalFormData, FormData, new OriginalFormData()); 7637 registerWrapper(OriginalFormData, FormData, new OriginalFormData());
7837 7638
7838 scope.wrappers.FormData = FormData; 7639 scope.wrappers.FormData = FormData;
7839 7640
7840 })(window.ShadowDOMPolyfill); 7641 })(window.ShadowDOMPolyfill);
7841 7642
7842 // Copyright 2013 The Polymer Authors. All rights reserved. 7643 // Copyright 2013 The Polymer Authors. All rights reserved.
7843 // Use of this source code is goverened by a BSD-style 7644 // Use of this source code is goverened by a BSD-style
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
8587 } else { 8388 } else {
8588 addCssToDocument(cssText); 8389 addCssToDocument(cssText);
8589 } 8390 }
8590 } 8391 }
8591 }; 8392 };
8592 8393
8593 var selectorRe = /([^{]*)({[\s\S]*?})/gim, 8394 var selectorRe = /([^{]*)({[\s\S]*?})/gim,
8594 cssCommentRe = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//gim, 8395 cssCommentRe = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//gim,
8595 // TODO(sorvell): remove either content or comment 8396 // TODO(sorvell): remove either content or comment
8596 cssCommentNextSelectorRe = /\/\*\s*@polyfill ([^*]*\*+([^/*][^*]*\*+)*\/)([^ {]*?){/gim, 8397 cssCommentNextSelectorRe = /\/\*\s*@polyfill ([^*]*\*+([^/*][^*]*\*+)*\/)([^ {]*?){/gim,
8597 cssContentNextSelectorRe = /polyfill-next-selector[^}]*content\:[\s]*?['"](. *?)['"][;\s]*}([^{]*?){/gim, 8398 cssContentNextSelectorRe = /polyfill-next-selector[^}]*content\:[\s]*['|"]([ ^'"]*)['|"][^}]*}([^{]*?){/gim,
8598 // TODO(sorvell): remove either content or comment 8399 // TODO(sorvell): remove either content or comment
8599 cssCommentRuleRe = /\/\*\s@polyfill-rule([^*]*\*+([^/*][^*]*\*+)*)\//gim, 8400 cssCommentRuleRe = /\/\*\s@polyfill-rule([^*]*\*+([^/*][^*]*\*+)*)\//gim,
8600 cssContentRuleRe = /(polyfill-rule)[^}]*(content\:[\s]*['"](.*?)['"])[;\s]*[ ^}]*}/gim, 8401 cssContentRuleRe = /(polyfill-rule)[^}]*(content\:[\s]*['|"]([^'"]*)['|"][^; ]*;)[^}]*}/gim,
8601 // TODO(sorvell): remove either content or comment 8402 // TODO(sorvell): remove either content or comment
8602 cssCommentUnscopedRuleRe = /\/\*\s@polyfill-unscoped-rule([^*]*\*+([^/*][^*] *\*+)*)\//gim, 8403 cssCommentUnscopedRuleRe = /\/\*\s@polyfill-unscoped-rule([^*]*\*+([^/*][^*] *\*+)*)\//gim,
8603 cssContentUnscopedRuleRe = /(polyfill-unscoped-rule)[^}]*(content\:[\s]*['"] (.*?)['"])[;\s]*[^}]*}/gim, 8404 cssContentUnscopedRuleRe = /(polyfill-unscoped-rule)[^}]*(content\:[\s]*['|" ]([^'"]*)['|"][^;]*;)[^}]*}/gim,
8604 cssPseudoRe = /::(x-[^\s{,(]*)/gim, 8405 cssPseudoRe = /::(x-[^\s{,(]*)/gim,
8605 cssPartRe = /::part\(([^)]*)\)/gim, 8406 cssPartRe = /::part\(([^)]*)\)/gim,
8606 // note: :host pre-processed to -shadowcsshost. 8407 // note: :host pre-processed to -shadowcsshost.
8607 polyfillHost = '-shadowcsshost', 8408 polyfillHost = '-shadowcsshost',
8608 // note: :host-context pre-processed to -shadowcsshostcontext. 8409 // note: :host-context pre-processed to -shadowcsshostcontext.
8609 polyfillHostContext = '-shadowcsscontext', 8410 polyfillHostContext = '-shadowcsscontext',
8610 parenSuffix = ')(?:\\((' + 8411 parenSuffix = ')(?:\\((' +
8611 '(?:\\([^)(]*\\)|[^)(]*)+?' + 8412 '(?:\\([^)(]*\\)|[^)(]*)+?' +
8612 ')\\))?([^,{]*)'; 8413 ')\\))?([^,{]*)';
8613 cssColonHostRe = new RegExp('(' + polyfillHost + parenSuffix, 'gim'), 8414 cssColonHostRe = new RegExp('(' + polyfillHost + parenSuffix, 'gim'),
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
8789 style.textContent = ShadowCSS.shimStyle(style); 8590 style.textContent = ShadowCSS.shimStyle(style);
8790 style.removeAttribute(SHIM_ATTRIBUTE, ''); 8591 style.removeAttribute(SHIM_ATTRIBUTE, '');
8791 style.setAttribute(SHIMMED_ATTRIBUTE, ''); 8592 style.setAttribute(SHIMMED_ATTRIBUTE, '');
8792 style[SHIMMED_ATTRIBUTE] = true; 8593 style[SHIMMED_ATTRIBUTE] = true;
8793 // place in document 8594 // place in document
8794 if (style.parentNode !== head) { 8595 if (style.parentNode !== head) {
8795 // replace links in head 8596 // replace links in head
8796 if (elt.parentNode === head) { 8597 if (elt.parentNode === head) {
8797 head.replaceChild(style, elt); 8598 head.replaceChild(style, elt);
8798 } else { 8599 } else {
8799 this.addElementToDocument(style); 8600 head.appendChild(style);
8800 } 8601 }
8801 } 8602 }
8802 style.__importParsed = true; 8603 style.__importParsed = true;
8803 this.markParsingComplete(elt); 8604 this.markParsingComplete(elt);
8804 this.parseNext(); 8605 this.parseNext();
8805 } 8606 }
8806 8607
8807 var hasResource = HTMLImports.parser.hasResource; 8608 var hasResource = HTMLImports.parser.hasResource;
8808 HTMLImports.parser.hasResource = function(node) { 8609 HTMLImports.parser.hasResource = function(node) {
8809 if (node.localName === 'link' && node.rel === 'stylesheet' && 8610 if (node.localName === 'link' && node.rel === 'stylesheet' &&
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
8864 frag.appendChild(inTemplate.firstChild); 8665 frag.appendChild(inTemplate.firstChild);
8865 } 8666 }
8866 inTemplate._content = frag; 8667 inTemplate._content = frag;
8867 } 8668 }
8868 return inTemplate.content || inTemplate._content; 8669 return inTemplate.content || inTemplate._content;
8869 }; 8670 };
8870 8671
8871 })(window.Platform); 8672 })(window.Platform);
8872 8673
8873 } 8674 }
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
8874 /* 9241 /*
8875 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. 9242 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
8876 * This code may only be used under the BSD style license found at http://polyme r.github.io/LICENSE.txt 9243 * This code may only be used under the BSD style license found at http://polyme r.github.io/LICENSE.txt
8877 * The complete set of authors may be found at http://polymer.github.io/AUTHORS. txt 9244 * The complete set of authors may be found at http://polymer.github.io/AUTHORS. txt
8878 * The complete set of contributors may be found at http://polymer.github.io/CON TRIBUTORS.txt 9245 * The complete set of contributors may be found at http://polymer.github.io/CON TRIBUTORS.txt
8879 * Code distributed by Google as part of the polymer project is also 9246 * Code distributed by Google as part of the polymer project is also
8880 * subject to an additional IP rights grant found at http://polymer.github.io/PA TENTS.txt 9247 * subject to an additional IP rights grant found at http://polymer.github.io/PA TENTS.txt
8881 */ 9248 */
8882 9249
8883 (function(scope) { 9250 (function(scope) {
(...skipping 1533 matching lines...) Expand 10 before | Expand all | Expand 10 after
10417 }, 10784 },
10418 parseStyle: function(elt) { 10785 parseStyle: function(elt) {
10419 // TODO(sorvell): style element load event can just not fire so clone styles 10786 // TODO(sorvell): style element load event can just not fire so clone styles
10420 var src = elt; 10787 var src = elt;
10421 elt = cloneStyle(elt); 10788 elt = cloneStyle(elt);
10422 elt.__importElement = src; 10789 elt.__importElement = src;
10423 this.parseGeneric(elt); 10790 this.parseGeneric(elt);
10424 }, 10791 },
10425 parseGeneric: function(elt) { 10792 parseGeneric: function(elt) {
10426 this.trackElement(elt); 10793 this.trackElement(elt);
10427 this.addElementToDocument(elt); 10794 document.head.appendChild(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);
10444 }, 10795 },
10445 // tracks when a loadable element has loaded 10796 // tracks when a loadable element has loaded
10446 trackElement: function(elt, callback) { 10797 trackElement: function(elt, callback) {
10447 var self = this; 10798 var self = this;
10448 var done = function(e) { 10799 var done = function(e) {
10449 if (callback) { 10800 if (callback) {
10450 callback(e); 10801 callback(e);
10451 } 10802 }
10452 self.markParsingComplete(elt); 10803 self.markParsingComplete(elt);
10453 self.parseNext(); 10804 self.parseNext();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
10490 parseScript: function(scriptElt) { 10841 parseScript: function(scriptElt) {
10491 var script = document.createElement('script'); 10842 var script = document.createElement('script');
10492 script.__importElement = scriptElt; 10843 script.__importElement = scriptElt;
10493 script.src = scriptElt.src ? scriptElt.src : 10844 script.src = scriptElt.src ? scriptElt.src :
10494 generateScriptDataUrl(scriptElt); 10845 generateScriptDataUrl(scriptElt);
10495 scope.currentScript = scriptElt; 10846 scope.currentScript = scriptElt;
10496 this.trackElement(script, function(e) { 10847 this.trackElement(script, function(e) {
10497 script.parentNode.removeChild(script); 10848 script.parentNode.removeChild(script);
10498 scope.currentScript = null; 10849 scope.currentScript = null;
10499 }); 10850 });
10500 this.addElementToDocument(script); 10851 document.head.appendChild(script);
10501 }, 10852 },
10502 // determine the next element in the tree which should be parsed 10853 // determine the next element in the tree which should be parsed
10503 nextToParse: function() { 10854 nextToParse: function() {
10504 return !this.parsingElement && this.nextToParseInDoc(mainDoc); 10855 return !this.parsingElement && this.nextToParseInDoc(mainDoc);
10505 }, 10856 },
10506 nextToParseInDoc: function(doc, link) { 10857 nextToParseInDoc: function(doc, link) {
10507 var nodes = doc.querySelectorAll(this.parseSelectorsForNode(doc)); 10858 var nodes = doc.querySelectorAll(this.parseSelectorsForNode(doc));
10508 for (var i=0, l=nodes.length, p=0, n; (i<l) && (n=nodes[i]); i++) { 10859 for (var i=0, l=nodes.length, p=0, n; (i<l) && (n=nodes[i]); i++) {
10509 if (!this.isParsed(n)) { 10860 if (!this.isParsed(n)) {
10510 if (this.hasResource(n)) { 10861 if (this.hasResource(n)) {
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
11036 (document.readyState === 'interactive' && !window.attachEvent)) { 11387 (document.readyState === 'interactive' && !window.attachEvent)) {
11037 bootstrap(); 11388 bootstrap();
11038 } else { 11389 } else {
11039 document.addEventListener('DOMContentLoaded', bootstrap); 11390 document.addEventListener('DOMContentLoaded', bootstrap);
11040 } 11391 }
11041 } 11392 }
11042 11393
11043 })(); 11394 })();
11044 11395
11045 /* 11396 /*
11046 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. 11397 * Copyright 2013 The Polymer Authors. All rights reserved.
11047 * This code may only be used under the BSD style license found at http://polyme r.github.io/LICENSE.txt 11398 * Use of this source code is governed by a BSD-style
11048 * The complete set of authors may be found at http://polymer.github.io/AUTHORS. txt 11399 * license that can be found in the LICENSE file.
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
11052 */ 11400 */
11053 window.CustomElements = window.CustomElements || {flags:{}}; 11401 window.CustomElements = window.CustomElements || {flags:{}};
11054 /* 11402 /*
11055 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. 11403 Copyright 2013 The Polymer Authors. All rights reserved.
11056 * This code may only be used under the BSD style license found at http://polyme r.github.io/LICENSE.txt 11404 Use of this source code is governed by a BSD-style
11057 * The complete set of authors may be found at http://polymer.github.io/AUTHORS. txt 11405 license that can be found in the LICENSE file.
11058 * The complete set of contributors may be found at http://polymer.github.io/CON TRIBUTORS.txt 11406 */
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 */
11062 11407
11063 (function(scope){ 11408 (function(scope){
11064 11409
11065 var logFlags = window.logFlags || {}; 11410 var logFlags = window.logFlags || {};
11066 var IMPORT_LINK_TYPE = window.HTMLImports ? HTMLImports.IMPORT_LINK_TYPE : 'none '; 11411 var IMPORT_LINK_TYPE = window.HTMLImports ? HTMLImports.IMPORT_LINK_TYPE : 'none ';
11067 11412
11068 // walk the subtree rooted at node, applying 'find(element, data)' function 11413 // walk the subtree rooted at node, applying 'find(element, data)' function
11069 // to each element 11414 // to each element
11070 // if 'find' returns true for 'element', do not search element's subtree 11415 // if 'find' returns true for 'element', do not search element's subtree
11071 function findAll(node, find, data) { 11416 function findAll(node, find, data) {
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
11393 scope.insertedNode = insertedNode; 11738 scope.insertedNode = insertedNode;
11394 11739
11395 scope.observeDocument = observeDocument; 11740 scope.observeDocument = observeDocument;
11396 scope.upgradeDocument = upgradeDocument; 11741 scope.upgradeDocument = upgradeDocument;
11397 11742
11398 scope.takeRecords = takeRecords; 11743 scope.takeRecords = takeRecords;
11399 11744
11400 })(window.CustomElements); 11745 })(window.CustomElements);
11401 11746
11402 /* 11747 /*
11403 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. 11748 * Copyright 2013 The Polymer Authors. All rights reserved.
11404 * This code may only be used under the BSD style license found at http://polyme r.github.io/LICENSE.txt 11749 * Use of this source code is governed by a BSD-style
11405 * The complete set of authors may be found at http://polymer.github.io/AUTHORS. txt 11750 * license that can be found in the LICENSE file.
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
11409 */ 11751 */
11410 11752
11411 /** 11753 /**
11412 * Implements `document.registerElement` 11754 * Implements `document.register`
11413 * @module CustomElements 11755 * @module CustomElements
11414 */ 11756 */
11415 11757
11416 /** 11758 /**
11417 * Polyfilled extensions to the `document` object. 11759 * Polyfilled extensions to the `document` object.
11418 * @class Document 11760 * @class Document
11419 */ 11761 */
11420 11762
11421 (function(scope) { 11763 (function(scope) {
11422 11764
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
11634 // output is a valid DOM element with the proper wrapper in place. 11976 // output is a valid DOM element with the proper wrapper in place.
11635 // 11977 //
11636 return upgrade(domCreateElement(definition.tag), definition); 11978 return upgrade(domCreateElement(definition.tag), definition);
11637 } 11979 }
11638 11980
11639 function upgrade(element, definition) { 11981 function upgrade(element, definition) {
11640 // some definitions specify an 'is' attribute 11982 // some definitions specify an 'is' attribute
11641 if (definition.is) { 11983 if (definition.is) {
11642 element.setAttribute('is', definition.is); 11984 element.setAttribute('is', definition.is);
11643 } 11985 }
11986 // remove 'unresolved' attr, which is a standin for :unresolved.
11987 element.removeAttribute('unresolved');
11644 // make 'element' implement definition.prototype 11988 // make 'element' implement definition.prototype
11645 implement(element, definition); 11989 implement(element, definition);
11646 // flag as upgraded 11990 // flag as upgraded
11647 element.__upgraded__ = true; 11991 element.__upgraded__ = true;
11648 // lifecycle management 11992 // lifecycle management
11649 created(element); 11993 created(element);
11650 // attachedCallback fires in tree order, call before recursing 11994 // attachedCallback fires in tree order, call before recursing
11651 scope.insertedNode(element); 11995 scope.insertedNode(element);
11652 // there should never be a shadow root on element at this point 11996 // there should never be a shadow root on element at this point
11653 scope.upgradeSubtree(element); 11997 scope.upgradeSubtree(element);
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
11871 12215
11872 // bc 12216 // bc
11873 document.register = document.registerElement; 12217 document.register = document.registerElement;
11874 12218
11875 scope.hasNative = hasNative; 12219 scope.hasNative = hasNative;
11876 scope.useNative = useNative; 12220 scope.useNative = useNative;
11877 12221
11878 })(window.CustomElements); 12222 })(window.CustomElements);
11879 12223
11880 /* 12224 /*
11881 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. 12225 * Copyright 2013 The Polymer Authors. All rights reserved.
11882 * This code may only be used under the BSD style license found at http://polyme r.github.io/LICENSE.txt 12226 * Use of this source code is governed by a BSD-style
11883 * The complete set of authors may be found at http://polymer.github.io/AUTHORS. txt 12227 * license that can be found in the LICENSE file.
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
11887 */ 12228 */
11888 12229
11889 (function(scope) { 12230 (function(scope) {
11890 12231
11891 // import 12232 // import
11892 12233
11893 var IMPORT_LINK_TYPE = scope.IMPORT_LINK_TYPE; 12234 var IMPORT_LINK_TYPE = scope.IMPORT_LINK_TYPE;
11894 12235
11895 // highlander object for parsing a document tree 12236 // highlander object for parsing a document tree
11896 12237
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
11938 12279
11939 var forEach = Array.prototype.forEach.call.bind(Array.prototype.forEach); 12280 var forEach = Array.prototype.forEach.call.bind(Array.prototype.forEach);
11940 12281
11941 // exports 12282 // exports
11942 12283
11943 scope.parser = parser; 12284 scope.parser = parser;
11944 scope.IMPORT_LINK_TYPE = IMPORT_LINK_TYPE; 12285 scope.IMPORT_LINK_TYPE = IMPORT_LINK_TYPE;
11945 12286
11946 })(window.CustomElements); 12287 })(window.CustomElements);
11947 /* 12288 /*
11948 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. 12289 * Copyright 2013 The Polymer Authors. All rights reserved.
11949 * This code may only be used under the BSD style license found at http://polyme r.github.io/LICENSE.txt 12290 * Use of this source code is governed by a BSD-style
11950 * The complete set of authors may be found at http://polymer.github.io/AUTHORS. txt 12291 * license that can be found in the LICENSE file.
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
11954 */ 12292 */
11955 (function(scope){ 12293 (function(scope){
11956 12294
11957 // bootstrap parsing 12295 // bootstrap parsing
11958 function bootstrap() { 12296 function bootstrap() {
11959 // parse document 12297 // parse document
11960 CustomElements.parser.parse(document); 12298 CustomElements.parser.parse(document);
11961 // one more pass before register is 'live' 12299 // one more pass before register is 'live'
11962 CustomElements.upgradeDocument(document); 12300 CustomElements.upgradeDocument(document);
11963 // choose async 12301 // choose async
(...skipping 18 matching lines...) Expand all
11982 if (window.HTMLImports) { 12320 if (window.HTMLImports) {
11983 HTMLImports.__importsParsingHook = function(elt) { 12321 HTMLImports.__importsParsingHook = function(elt) {
11984 CustomElements.parser.parse(elt.import); 12322 CustomElements.parser.parse(elt.import);
11985 } 12323 }
11986 } 12324 }
11987 }); 12325 });
11988 } 12326 }
11989 12327
11990 // CustomEvent shim for IE 12328 // CustomEvent shim for IE
11991 if (typeof window.CustomEvent !== 'function') { 12329 if (typeof window.CustomEvent !== 'function') {
11992 window.CustomEvent = function(inType, params) { 12330 window.CustomEvent = function(inType) {
11993 params = params || {}; 12331 var e = document.createEvent('HTMLEvents');
11994 var e = document.createEvent('CustomEvent'); 12332 e.initEvent(inType, true, true);
11995 e.initCustomEvent(inType, Boolean(params.bubbles), Boolean(params.cancelable ), params.detail);
11996 return e; 12333 return e;
11997 }; 12334 };
11998 window.CustomEvent.prototype = window.Event.prototype;
11999 } 12335 }
12000 12336
12001 // When loading at readyState complete time (or via flag), boot custom elements 12337 // When loading at readyState complete time (or via flag), boot custom elements
12002 // immediately. 12338 // immediately.
12003 // If relevant, HTMLImports must already be loaded. 12339 // If relevant, HTMLImports must already be loaded.
12004 if (document.readyState === 'complete' || scope.flags.eager) { 12340 if (document.readyState === 'complete' || scope.flags.eager) {
12005 bootstrap(); 12341 bootstrap();
12006 // When loading at readyState interactive time, bootstrap only if HTMLImports 12342 // When loading at readyState interactive time, bootstrap only if HTMLImports
12007 // are not pending. Also avoid IE as the semantics of this state are unreliable. 12343 // are not pending. Also avoid IE as the semantics of this state are unreliable.
12008 } else if (document.readyState === 'interactive' && !window.attachEvent && 12344 } else if (document.readyState === 'interactive' && !window.attachEvent &&
(...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after
13153 get bindingDelegate() { 13489 get bindingDelegate() {
13154 return this.delegate_ && this.delegate_.raw; 13490 return this.delegate_ && this.delegate_.raw;
13155 }, 13491 },
13156 13492
13157 refChanged_: function() { 13493 refChanged_: function() {
13158 if (!this.iterator_ || this.refContent_ === this.ref_.content) 13494 if (!this.iterator_ || this.refContent_ === this.ref_.content)
13159 return; 13495 return;
13160 13496
13161 this.refContent_ = undefined; 13497 this.refContent_ = undefined;
13162 this.iterator_.valueChanged(); 13498 this.iterator_.valueChanged();
13163 this.iterator_.updateIteratedValue(this.iterator_.getUpdatedValue()); 13499 this.iterator_.updateIteratedValue();
13164 }, 13500 },
13165 13501
13166 clear: function() { 13502 clear: function() {
13167 this.model_ = undefined; 13503 this.model_ = undefined;
13168 this.delegate_ = undefined; 13504 this.delegate_ = undefined;
13169 if (this.bindings_ && this.bindings_.ref) 13505 if (this.bindings_ && this.bindings_.ref)
13170 this.bindings_.ref.close() 13506 this.bindings_.ref.close()
13171 this.refContent_ = undefined; 13507 this.refContent_ = undefined;
13172 if (!this.iterator_) 13508 if (!this.iterator_)
13173 return; 13509 return;
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
13557 deps.value.close(); 13893 deps.value.close();
13558 } 13894 }
13559 }, 13895 },
13560 13896
13561 updateDependencies: function(directives, model) { 13897 updateDependencies: function(directives, model) {
13562 this.closeDeps(); 13898 this.closeDeps();
13563 13899
13564 var deps = this.deps = {}; 13900 var deps = this.deps = {};
13565 var template = this.templateElement_; 13901 var template = this.templateElement_;
13566 13902
13567 var ifValue = true;
13568 if (directives.if) { 13903 if (directives.if) {
13569 deps.hasIf = true; 13904 deps.hasIf = true;
13570 deps.ifOneTime = directives.if.onlyOneTime; 13905 deps.ifOneTime = directives.if.onlyOneTime;
13571 deps.ifValue = processBinding(IF, directives.if, template, model); 13906 deps.ifValue = processBinding(IF, directives.if, template, model);
13572 13907
13573 ifValue = deps.ifValue;
13574
13575 // oneTime if & predicate is false. nothing else to do. 13908 // oneTime if & predicate is false. nothing else to do.
13576 if (deps.ifOneTime && !ifValue) { 13909 if (deps.ifOneTime && !deps.ifValue) {
13577 this.valueChanged(); 13910 this.updateIteratedValue();
13578 return; 13911 return;
13579 } 13912 }
13580 13913
13581 if (!deps.ifOneTime) 13914 if (!deps.ifOneTime)
13582 ifValue = ifValue.open(this.updateIfValue, this); 13915 deps.ifValue.open(this.updateIteratedValue, this);
13583 } 13916 }
13584 13917
13585 if (directives.repeat) { 13918 if (directives.repeat) {
13586 deps.repeat = true; 13919 deps.repeat = true;
13587 deps.oneTime = directives.repeat.onlyOneTime; 13920 deps.oneTime = directives.repeat.onlyOneTime;
13588 deps.value = processBinding(REPEAT, directives.repeat, template, model); 13921 deps.value = processBinding(REPEAT, directives.repeat, template, model);
13589 } else { 13922 } else {
13590 deps.repeat = false; 13923 deps.repeat = false;
13591 deps.oneTime = directives.bind.onlyOneTime; 13924 deps.oneTime = directives.bind.onlyOneTime;
13592 deps.value = processBinding(BIND, directives.bind, template, model); 13925 deps.value = processBinding(BIND, directives.bind, template, model);
13593 } 13926 }
13594 13927
13595 var value = deps.value;
13596 if (!deps.oneTime) 13928 if (!deps.oneTime)
13597 value = value.open(this.updateIteratedValue, this); 13929 deps.value.open(this.updateIteratedValue, this);
13598 13930
13599 if (!ifValue) { 13931 this.updateIteratedValue();
13600 this.valueChanged();
13601 return;
13602 }
13603
13604 this.updateValue(value);
13605 }, 13932 },
13606 13933
13607 /** 13934 updateIteratedValue: function() {
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) {
13629 if (this.deps.hasIf) { 13935 if (this.deps.hasIf) {
13630 var ifValue = this.deps.ifValue; 13936 var ifValue = this.deps.ifValue;
13631 if (!this.deps.ifOneTime) 13937 if (!this.deps.ifOneTime)
13632 ifValue = ifValue.discardChanges(); 13938 ifValue = ifValue.discardChanges();
13633 if (!ifValue) { 13939 if (!ifValue) {
13634 this.valueChanged(); 13940 this.valueChanged();
13635 return; 13941 return;
13636 } 13942 }
13637 } 13943 }
13638 13944
13639 this.updateValue(value); 13945 var value = this.deps.value;
13640 }, 13946 if (!this.deps.oneTime)
13641 13947 value = value.discardChanges();
13642 updateValue: function(value) {
13643 if (!this.deps.repeat) 13948 if (!this.deps.repeat)
13644 value = [value]; 13949 value = [value];
13645 var observe = this.deps.repeat && 13950 var observe = this.deps.repeat &&
13646 !this.deps.oneTime && 13951 !this.deps.oneTime &&
13647 Array.isArray(value); 13952 Array.isArray(value);
13648 this.valueChanged(value, observe); 13953 this.valueChanged(value, observe);
13649 }, 13954 },
13650 13955
13651 valueChanged: function(value, observeValue) { 13956 valueChanged: function(value, observeValue) {
13652 if (!Array.isArray(value)) 13957 if (!Array.isArray(value))
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
13923 } 14228 }
13924 } 14229 }
13925 14230
13926 // exports 14231 // exports
13927 scope.flush = flush; 14232 scope.flush = flush;
13928 14233
13929 })(window.Platform); 14234 })(window.Platform);
13930 14235
13931 14236
13932 //# sourceMappingURL=platform.concat.js.map 14237 //# sourceMappingURL=platform.concat.js.map
OLDNEW
« no previous file with comments | « pkg/web_components/lib/platform.js ('k') | pkg/web_components/lib/platform.concat.js.map » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698