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

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

Issue 588373003: Update to polymer js version 0.4.1 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: review updates Created 6 years, 3 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 } 108 }
109 }; 109 };
110 110
111 window.WeakMap = WeakMap; 111 window.WeakMap = WeakMap;
112 })(); 112 })();
113 } 113 }
114 114
115 // select ShadowDOM impl 115 // select ShadowDOM impl
116 if (Platform.flags.shadow) { 116 if (Platform.flags.shadow) {
117 117
118 // Copyright 2012 Google Inc. 118 /*
119 // 119 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
120 // Licensed under the Apache License, Version 2.0 (the "License"); 120 * This code may only be used under the BSD style license found at http://polyme r.github.io/LICENSE.txt
121 // you may not use this file except in compliance with the License. 121 * The complete set of authors may be found at http://polymer.github.io/AUTHORS. txt
122 // You may obtain a copy of the License at 122 * The complete set of contributors may be found at http://polymer.github.io/CON TRIBUTORS.txt
123 // 123 * Code distributed by Google as part of the polymer project is also
124 // http://www.apache.org/licenses/LICENSE-2.0 124 * subject to an additional IP rights grant found at http://polymer.github.io/PA TENTS.txt
125 // 125 */
126 // Unless required by applicable law or agreed to in writing, software
127 // distributed under the License is distributed on an "AS IS" BASIS,
128 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
129 // See the License for the specific language governing permissions and
130 // limitations under the License.
131 126
132 (function(global) { 127 (function(global) {
133 'use strict'; 128 'use strict';
134 129
135 var testingExposeCycleCount = global.testingExposeCycleCount; 130 var testingExposeCycleCount = global.testingExposeCycleCount;
136 131
137 // Detect and do basic sanity checking on Object/Array.observe. 132 // Detect and do basic sanity checking on Object/Array.observe.
138 function detectObjectObserve() { 133 function detectObjectObserve() {
139 if (typeof Object.observe !== 'function' || 134 if (typeof Object.observe !== 'function' ||
140 typeof Array.observe !== 'function') { 135 typeof Array.observe !== 'function') {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 function detectEval() { 175 function detectEval() {
181 // Don't test for eval if we're running in a Chrome App environment. 176 // Don't test for eval if we're running in a Chrome App environment.
182 // We check for APIs set that only exist in a Chrome App context. 177 // We check for APIs set that only exist in a Chrome App context.
183 if (typeof chrome !== 'undefined' && chrome.app && chrome.app.runtime) { 178 if (typeof chrome !== 'undefined' && chrome.app && chrome.app.runtime) {
184 return false; 179 return false;
185 } 180 }
186 181
187 // Firefox OS Apps do not allow eval. This feature detection is very hacky 182 // Firefox OS Apps do not allow eval. This feature detection is very hacky
188 // but even if some other platform adds support for this function this code 183 // but even if some other platform adds support for this function this code
189 // will continue to work. 184 // will continue to work.
190 if (navigator.getDeviceStorage) { 185 if (typeof navigator != 'undefined' && navigator.getDeviceStorage) {
191 return false; 186 return false;
192 } 187 }
193 188
194 try { 189 try {
195 var f = new Function('', 'return true;'); 190 var f = new Function('', 'return true;');
196 return f(); 191 return f();
197 } catch (ex) { 192 } catch (ex) {
198 return false; 193 return false;
199 } 194 }
200 } 195 }
201 196
202 var hasEval = detectEval(); 197 var hasEval = detectEval();
203 198
204 function isIndex(s) { 199 function isIndex(s) {
205 return +s === s >>> 0; 200 return +s === s >>> 0 && s !== '';
206 } 201 }
207 202
208 function toNumber(s) { 203 function toNumber(s) {
209 return +s; 204 return +s;
210 } 205 }
211 206
212 function isObject(obj) { 207 function isObject(obj) {
213 return obj === Object(obj); 208 return obj === Object(obj);
214 } 209 }
215 210
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 904
910 allObservers.push(observer); 905 allObservers.push(observer);
911 } 906 }
912 907
913 function removeFromAll(observer) { 908 function removeFromAll(observer) {
914 Observer._allObserversCount--; 909 Observer._allObserversCount--;
915 } 910 }
916 911
917 var runningMicrotaskCheckpoint = false; 912 var runningMicrotaskCheckpoint = false;
918 913
919 var hasDebugForceFullDelivery = hasObserve && hasEval && (function() {
920 try {
921 eval('%RunMicrotasks()');
922 return true;
923 } catch (ex) {
924 return false;
925 }
926 })();
927
928 global.Platform = global.Platform || {}; 914 global.Platform = global.Platform || {};
929 915
930 global.Platform.performMicrotaskCheckpoint = function() { 916 global.Platform.performMicrotaskCheckpoint = function() {
931 if (runningMicrotaskCheckpoint) 917 if (runningMicrotaskCheckpoint)
932 return; 918 return;
933 919
934 if (hasDebugForceFullDelivery) {
935 eval('%RunMicrotasks()');
936 return;
937 }
938
939 if (!collectObservers) 920 if (!collectObservers)
940 return; 921 return;
941 922
942 runningMicrotaskCheckpoint = true; 923 runningMicrotaskCheckpoint = true;
943 924
944 var cycles = 0; 925 var cycles = 0;
945 var anyChanged, toCheck; 926 var anyChanged, toCheck;
946 927
947 do { 928 do {
948 cycles++; 929 cycles++;
(...skipping 2062 matching lines...) Expand 10 before | Expand all | Expand 10 after
3011 return; 2992 return;
3012 handledEventsTable.set(originalEvent, true); 2993 handledEventsTable.set(originalEvent, true);
3013 dispatchEvent(wrap(originalEvent), wrap(originalEvent.target)); 2994 dispatchEvent(wrap(originalEvent), wrap(originalEvent.target));
3014 if (pendingError) { 2995 if (pendingError) {
3015 var err = pendingError; 2996 var err = pendingError;
3016 pendingError = null; 2997 pendingError = null;
3017 throw err; 2998 throw err;
3018 } 2999 }
3019 } 3000 }
3020 3001
3002
3003 function isLoadLikeEvent(event) {
3004 switch (event.type) {
3005 // http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis. html#events-and-the-window-object
3006 case 'load':
3007 // http://www.whatwg.org/specs/web-apps/current-work/multipage/browsers.ht ml#unloading-documents
3008 case 'beforeunload':
3009 case 'unload':
3010 return true;
3011 }
3012 return false;
3013 }
3014
3021 function dispatchEvent(event, originalWrapperTarget) { 3015 function dispatchEvent(event, originalWrapperTarget) {
3022 if (currentlyDispatchingEvents.get(event)) 3016 if (currentlyDispatchingEvents.get(event))
3023 throw new Error('InvalidStateError'); 3017 throw new Error('InvalidStateError');
3024 3018
3025 currentlyDispatchingEvents.set(event, true); 3019 currentlyDispatchingEvents.set(event, true);
3026 3020
3027 // Render to ensure that the event path is correct. 3021 // Render to ensure that the event path is correct.
3028 scope.renderAllPending(); 3022 scope.renderAllPending();
3029 var eventPath; 3023 var eventPath;
3030 3024
3031 // http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.ht ml#events-and-the-window-object 3025 // http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.ht ml#events-and-the-window-object
3032 // All events dispatched on Nodes with a default view, except load events, 3026 // All events dispatched on Nodes with a default view, except load events,
3033 // should propagate to the Window. 3027 // should propagate to the Window.
3034 3028
3035 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html# the-end 3029 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html# the-end
3036 var overrideTarget; 3030 var overrideTarget;
3037 var win; 3031 var win;
3038 var type = event.type;
3039 3032
3040 // Should really be not cancelable too but since Firefox has a bug there 3033 // Should really be not cancelable too but since Firefox has a bug there
3041 // we skip that check. 3034 // we skip that check.
3042 // https://bugzilla.mozilla.org/show_bug.cgi?id=999456 3035 // https://bugzilla.mozilla.org/show_bug.cgi?id=999456
3043 if (type === 'load' && !event.bubbles) { 3036 if (isLoadLikeEvent(event) && !event.bubbles) {
3044 var doc = originalWrapperTarget; 3037 var doc = originalWrapperTarget;
3045 if (doc instanceof wrappers.Document && (win = doc.defaultView)) { 3038 if (doc instanceof wrappers.Document && (win = doc.defaultView)) {
3046 overrideTarget = doc; 3039 overrideTarget = doc;
3047 eventPath = []; 3040 eventPath = [];
3048 } 3041 }
3049 } 3042 }
3050 3043
3051 if (!eventPath) { 3044 if (!eventPath) {
3052 if (originalWrapperTarget instanceof wrappers.Window) { 3045 if (originalWrapperTarget instanceof wrappers.Window) {
3053 win = originalWrapperTarget; 3046 win = originalWrapperTarget;
3054 eventPath = []; 3047 eventPath = [];
3055 } else { 3048 } else {
3056 eventPath = getEventPath(originalWrapperTarget, event); 3049 eventPath = getEventPath(originalWrapperTarget, event);
3057 3050
3058 if (event.type !== 'load') { 3051 if (!isLoadLikeEvent(event)) {
3059 var doc = eventPath[eventPath.length - 1]; 3052 var doc = eventPath[eventPath.length - 1];
3060 if (doc instanceof wrappers.Document) 3053 if (doc instanceof wrappers.Document)
3061 win = doc.defaultView; 3054 win = doc.defaultView;
3062 } 3055 }
3063 } 3056 }
3064 } 3057 }
3065 3058
3066 eventPathTable.set(event, eventPath); 3059 eventPathTable.set(event, eventPath);
3067 3060
3068 if (dispatchCapturing(event, eventPath, win, overrideTarget)) { 3061 if (dispatchCapturing(event, eventPath, win, overrideTarget)) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
3154 adjusted = null; 3147 adjusted = null;
3155 } 3148 }
3156 relatedTargetTable.set(event, adjusted); 3149 relatedTargetTable.set(event, adjusted);
3157 } 3150 }
3158 } 3151 }
3159 3152
3160 eventPhaseTable.set(event, phase); 3153 eventPhaseTable.set(event, phase);
3161 var type = event.type; 3154 var type = event.type;
3162 3155
3163 var anyRemoved = false; 3156 var anyRemoved = false;
3164 // targetTable.set(event, target);
3165 targetTable.set(event, target); 3157 targetTable.set(event, target);
3166 currentTargetTable.set(event, currentTarget); 3158 currentTargetTable.set(event, currentTarget);
3167 3159
3168 // Keep track of the invoke depth so that we only clean up the removed 3160 // Keep track of the invoke depth so that we only clean up the removed
3169 // listeners if we are in the outermost invoke. 3161 // listeners if we are in the outermost invoke.
3170 listeners.depth++; 3162 listeners.depth++;
3171 3163
3172 for (var i = 0, len = listeners.length; i < len; i++) { 3164 for (var i = 0, len = listeners.length; i < len; i++) {
3173 var listener = listeners[i]; 3165 var listener = listeners[i];
3174 if (listener.removed) { 3166 if (listener.removed) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
3239 3231
3240 /** 3232 /**
3241 * Creates a new Event wrapper or wraps an existin native Event object. 3233 * Creates a new Event wrapper or wraps an existin native Event object.
3242 * @param {string|Event} type 3234 * @param {string|Event} type
3243 * @param {Object=} options 3235 * @param {Object=} options
3244 * @constructor 3236 * @constructor
3245 */ 3237 */
3246 function Event(type, options) { 3238 function Event(type, options) {
3247 if (type instanceof OriginalEvent) { 3239 if (type instanceof OriginalEvent) {
3248 var impl = type; 3240 var impl = type;
3249 if (!OriginalBeforeUnloadEvent && impl.type === 'beforeunload') { 3241 // In browsers that do not correctly support BeforeUnloadEvent we get to
3242 // the generic Event wrapper but we still want to ensure we create a
3243 // BeforeUnloadEvent. Since BeforeUnloadEvent calls super, we need to
3244 // prevent reentrancty.
3245 if (!OriginalBeforeUnloadEvent && impl.type === 'beforeunload' &&
3246 !(this instanceof BeforeUnloadEvent)) {
3250 return new BeforeUnloadEvent(impl); 3247 return new BeforeUnloadEvent(impl);
3251 } 3248 }
3252 setWrapper(impl, this); 3249 setWrapper(impl, this);
3253 } else { 3250 } else {
3254 return wrap(constructEvent(OriginalEvent, 'Event', type, options)); 3251 return wrap(constructEvent(OriginalEvent, 'Event', type, options));
3255 } 3252 }
3256 } 3253 }
3257 Event.prototype = { 3254 Event.prototype = {
3258 get target() { 3255 get target() {
3259 return targetTable.get(this); 3256 return targetTable.get(this);
(...skipping 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after
4603 registerWrapper(OriginalNode, Node, document.createDocumentFragment()); 4600 registerWrapper(OriginalNode, Node, document.createDocumentFragment());
4604 delete Node.prototype.querySelector; 4601 delete Node.prototype.querySelector;
4605 delete Node.prototype.querySelectorAll; 4602 delete Node.prototype.querySelectorAll;
4606 Node.prototype = mixin(Object.create(EventTarget.prototype), Node.prototype); 4603 Node.prototype = mixin(Object.create(EventTarget.prototype), Node.prototype);
4607 4604
4608 scope.cloneNode = cloneNode; 4605 scope.cloneNode = cloneNode;
4609 scope.nodeWasAdded = nodeWasAdded; 4606 scope.nodeWasAdded = nodeWasAdded;
4610 scope.nodeWasRemoved = nodeWasRemoved; 4607 scope.nodeWasRemoved = nodeWasRemoved;
4611 scope.nodesWereAdded = nodesWereAdded; 4608 scope.nodesWereAdded = nodesWereAdded;
4612 scope.nodesWereRemoved = nodesWereRemoved; 4609 scope.nodesWereRemoved = nodesWereRemoved;
4610 scope.originalInsertBefore = originalInsertBefore;
4611 scope.originalRemoveChild = originalRemoveChild;
4613 scope.snapshotNodeList = snapshotNodeList; 4612 scope.snapshotNodeList = snapshotNodeList;
4614 scope.wrappers.Node = Node; 4613 scope.wrappers.Node = Node;
4615 4614
4616 })(window.ShadowDOMPolyfill); 4615 })(window.ShadowDOMPolyfill);
4617 4616
4618 // Copyright 2013 The Polymer Authors. All rights reserved. 4617 // Copyright 2013 The Polymer Authors. All rights reserved.
4619 // Use of this source code is governed by a BSD-style 4618 // Use of this source code is governed by a BSD-style
4620 // license that can be found in the LICENSE file. 4619 // license that can be found in the LICENSE file.
4621 4620
4622 (function(scope) { 4621 (function(scope) {
(...skipping 2084 matching lines...) Expand 10 before | Expand all | Expand 10 after
6707 var lastChildWrapper = wrap(parentNode.lastChild); 6706 var lastChildWrapper = wrap(parentNode.lastChild);
6708 if (lastChildWrapper) 6707 if (lastChildWrapper)
6709 lastChildWrapper.nextSibling_ = lastChildWrapper.nextSibling; 6708 lastChildWrapper.nextSibling_ = lastChildWrapper.nextSibling;
6710 } else { 6709 } else {
6711 if (parentNodeWrapper.firstChild === refChildWrapper) 6710 if (parentNodeWrapper.firstChild === refChildWrapper)
6712 parentNodeWrapper.firstChild_ = refChildWrapper; 6711 parentNodeWrapper.firstChild_ = refChildWrapper;
6713 6712
6714 refChildWrapper.previousSibling_ = refChildWrapper.previousSibling; 6713 refChildWrapper.previousSibling_ = refChildWrapper.previousSibling;
6715 } 6714 }
6716 6715
6717 parentNode.insertBefore(newChild, refChild); 6716 scope.originalInsertBefore.call(parentNode, newChild, refChild);
6718 } 6717 }
6719 6718
6720 function remove(nodeWrapper) { 6719 function remove(nodeWrapper) {
6721 var node = unwrap(nodeWrapper) 6720 var node = unwrap(nodeWrapper)
6722 var parentNode = node.parentNode; 6721 var parentNode = node.parentNode;
6723 if (!parentNode) 6722 if (!parentNode)
6724 return; 6723 return;
6725 6724
6726 var parentNodeWrapper = wrap(parentNode); 6725 var parentNodeWrapper = wrap(parentNode);
6727 updateWrapperUpAndSideways(nodeWrapper); 6726 updateWrapperUpAndSideways(nodeWrapper);
6728 6727
6729 if (nodeWrapper.previousSibling) 6728 if (nodeWrapper.previousSibling)
6730 nodeWrapper.previousSibling.nextSibling_ = nodeWrapper; 6729 nodeWrapper.previousSibling.nextSibling_ = nodeWrapper;
6731 if (nodeWrapper.nextSibling) 6730 if (nodeWrapper.nextSibling)
6732 nodeWrapper.nextSibling.previousSibling_ = nodeWrapper; 6731 nodeWrapper.nextSibling.previousSibling_ = nodeWrapper;
6733 6732
6734 if (parentNodeWrapper.lastChild === nodeWrapper) 6733 if (parentNodeWrapper.lastChild === nodeWrapper)
6735 parentNodeWrapper.lastChild_ = nodeWrapper; 6734 parentNodeWrapper.lastChild_ = nodeWrapper;
6736 if (parentNodeWrapper.firstChild === nodeWrapper) 6735 if (parentNodeWrapper.firstChild === nodeWrapper)
6737 parentNodeWrapper.firstChild_ = nodeWrapper; 6736 parentNodeWrapper.firstChild_ = nodeWrapper;
6738 6737
6739 parentNode.removeChild(node); 6738 scope.originalRemoveChild.call(parentNode, node);
6740 } 6739 }
6741 6740
6742 var distributedNodesTable = new WeakMap(); 6741 var distributedNodesTable = new WeakMap();
6743 var destinationInsertionPointsTable = new WeakMap(); 6742 var destinationInsertionPointsTable = new WeakMap();
6744 var rendererForHostTable = new WeakMap(); 6743 var rendererForHostTable = new WeakMap();
6745 6744
6746 function resetDistributedNodes(insertionPoint) { 6745 function resetDistributedNodes(insertionPoint) {
6747 distributedNodesTable.set(insertionPoint, []); 6746 distributedNodesTable.set(insertionPoint, []);
6748 } 6747 }
6749 6748
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
6932 parentRenderer.invalidate(); 6931 parentRenderer.invalidate();
6933 pendingDirtyRenderers.push(this); 6932 pendingDirtyRenderers.push(this);
6934 if (renderTimer) 6933 if (renderTimer)
6935 return; 6934 return;
6936 renderTimer = window[request](handleRequestAnimationFrame, 0); 6935 renderTimer = window[request](handleRequestAnimationFrame, 0);
6937 } 6936 }
6938 }, 6937 },
6939 6938
6940 // http://w3c.github.io/webcomponents/spec/shadow/#distribution-algorithms 6939 // http://w3c.github.io/webcomponents/spec/shadow/#distribution-algorithms
6941 distribution: function(root) { 6940 distribution: function(root) {
6942 this.resetAll(root); 6941 this.resetAllSubtrees(root);
6943 this.distributionResolution(root); 6942 this.distributionResolution(root);
6944 }, 6943 },
6945 6944
6946 resetAll: function(node) { 6945 resetAll: function(node) {
6947 if (isInsertionPoint(node)) 6946 if (isInsertionPoint(node))
6948 resetDistributedNodes(node); 6947 resetDistributedNodes(node);
6949 else 6948 else
6950 resetDestinationInsertionPoints(node); 6949 resetDestinationInsertionPoints(node);
6951 6950
6951 this.resetAllSubtrees(node);
6952 },
6953
6954 resetAllSubtrees: function(node) {
6952 for (var child = node.firstChild; child; child = child.nextSibling) { 6955 for (var child = node.firstChild; child; child = child.nextSibling) {
6953 this.resetAll(child); 6956 this.resetAll(child);
6954 } 6957 }
6955 6958
6956 if (node.shadowRoot) 6959 if (node.shadowRoot)
6957 this.resetAll(node.shadowRoot); 6960 this.resetAll(node.shadowRoot);
6958 6961
6959 if (node.olderShadowRoot) 6962 if (node.olderShadowRoot)
6960 this.resetAll(node.olderShadowRoot); 6963 this.resetAll(node.olderShadowRoot);
6961 }, 6964 },
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after
7882 */ 7885 */
7883 7886
7884 (function(scope) { 7887 (function(scope) {
7885 'use strict'; 7888 'use strict';
7886 7889
7887 var registerWrapper = scope.registerWrapper; 7890 var registerWrapper = scope.registerWrapper;
7888 var setWrapper = scope.setWrapper; 7891 var setWrapper = scope.setWrapper;
7889 var unwrap = scope.unwrap; 7892 var unwrap = scope.unwrap;
7890 7893
7891 var OriginalFormData = window.FormData; 7894 var OriginalFormData = window.FormData;
7895 if (!OriginalFormData) return;
7892 7896
7893 function FormData(formElement) { 7897 function FormData(formElement) {
7894 var impl; 7898 var impl;
7895 if (formElement instanceof OriginalFormData) { 7899 if (formElement instanceof OriginalFormData) {
7896 impl = formElement; 7900 impl = formElement;
7897 } else { 7901 } else {
7898 impl = new OriginalFormData(formElement && unwrap(formElement)); 7902 impl = new OriginalFormData(formElement && unwrap(formElement));
7899 } 7903 }
7900 setWrapper(impl, this); 7904 setWrapper(impl, this);
7901 } 7905 }
7902 7906
7903 registerWrapper(OriginalFormData, FormData, new OriginalFormData()); 7907 registerWrapper(OriginalFormData, FormData, new OriginalFormData());
7904 7908
7905 scope.wrappers.FormData = FormData; 7909 scope.wrappers.FormData = FormData;
7906 7910
7907 })(window.ShadowDOMPolyfill); 7911 })(window.ShadowDOMPolyfill);
7908 7912
7913 /*
7914 * Copyright 2014 The Polymer Authors. All rights reserved.
7915 * Use of this source code is goverened by a BSD-style
7916 * license that can be found in the LICENSE file.
7917 */
7918
7919 (function(scope) {
7920 'use strict';
7921
7922 var unwrapIfNeeded = scope.unwrapIfNeeded;
7923 var originalSend = XMLHttpRequest.prototype.send;
7924
7925 // Since we only need to adjust XHR.send, we just patch it instead of wrapping
7926 // the entire object. This happens when FormData is passed.
7927 XMLHttpRequest.prototype.send = function(obj) {
7928 return originalSend.call(this, unwrapIfNeeded(obj));
7929 };
7930
7931 })(window.ShadowDOMPolyfill);
7932
7909 // Copyright 2013 The Polymer Authors. All rights reserved. 7933 // Copyright 2013 The Polymer Authors. All rights reserved.
7910 // Use of this source code is goverened by a BSD-style 7934 // Use of this source code is goverened by a BSD-style
7911 // license that can be found in the LICENSE file. 7935 // license that can be found in the LICENSE file.
7912 7936
7913 (function(scope) { 7937 (function(scope) {
7914 'use strict'; 7938 'use strict';
7915 7939
7916 var isWrapperFor = scope.isWrapperFor; 7940 var isWrapperFor = scope.isWrapperFor;
7917 7941
7918 // This is a list of the elements we currently override the global constructor 7942 // This is a list of the elements we currently override the global constructor
(...skipping 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after
9526 var args2 = args.slice(); 9550 var args2 = args.slice();
9527 args2.push.apply(args2, arguments); 9551 args2.push.apply(args2, arguments);
9528 return self.apply(scope, args2); 9552 return self.apply(scope, args2);
9529 }; 9553 };
9530 }; 9554 };
9531 } 9555 }
9532 9556
9533 })(window.Platform); 9557 })(window.Platform);
9534 9558
9535 /* 9559 /*
9536 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
9537 * This code may only be used under the BSD style license found at http://polyme r.github.io/LICENSE.txt
9538 * The complete set of authors may be found at http://polymer.github.io/AUTHORS. txt
9539 * The complete set of contributors may be found at http://polymer.github.io/CON TRIBUTORS.txt
9540 * Code distributed by Google as part of the polymer project is also
9541 * subject to an additional IP rights grant found at http://polymer.github.io/PA TENTS.txt
9542 */
9543
9544 (function(scope) {
9545
9546 'use strict';
9547
9548 // polyfill performance.now
9549
9550 if (!window.performance) {
9551 var start = Date.now();
9552 // only at millisecond precision
9553 window.performance = {now: function(){ return Date.now() - start }};
9554 }
9555
9556 // polyfill for requestAnimationFrame
9557
9558 if (!window.requestAnimationFrame) {
9559 window.requestAnimationFrame = (function() {
9560 var nativeRaf = window.webkitRequestAnimationFrame ||
9561 window.mozRequestAnimationFrame;
9562
9563 return nativeRaf ?
9564 function(callback) {
9565 return nativeRaf(function() {
9566 callback(performance.now());
9567 });
9568 } :
9569 function( callback ){
9570 return window.setTimeout(callback, 1000 / 60);
9571 };
9572 })();
9573 }
9574
9575 if (!window.cancelAnimationFrame) {
9576 window.cancelAnimationFrame = (function() {
9577 return window.webkitCancelAnimationFrame ||
9578 window.mozCancelAnimationFrame ||
9579 function(id) {
9580 clearTimeout(id);
9581 };
9582 })();
9583 }
9584
9585 // Make a stub for Polymer() for polyfill purposes; under the HTMLImports
9586 // polyfill, scripts in the main document run before imports. That means
9587 // if (1) polymer is imported and (2) Polymer() is called in the main document
9588 // in a script after the import, 2 occurs before 1. We correct this here
9589 // by specfiically patching Polymer(); this is not necessary under native
9590 // HTMLImports.
9591 var elementDeclarations = [];
9592
9593 var polymerStub = function(name, dictionary) {
9594 Array.prototype.push.call(arguments, document._currentScript);
9595 elementDeclarations.push(arguments);
9596 };
9597 window.Polymer = polymerStub;
9598
9599 // deliver queued delcarations
9600 scope.consumeDeclarations = function(callback) {
9601 scope.consumeDeclarations = function() {
9602 throw 'Possible attempt to load Polymer twice';
9603 };
9604 if (callback) {
9605 callback(elementDeclarations);
9606 }
9607 elementDeclarations = null;
9608 };
9609
9610 // Once DOMContent has loaded, any main document scripts that depend on
9611 // Polymer() should have run. Calling Polymer() now is an error until
9612 // polymer is imported.
9613 window.addEventListener('DOMContentLoaded', function() {
9614 if (window.Polymer === polymerStub) {
9615 window.Polymer = function() {
9616 console.error('You tried to use polymer without loading it first. To ' +
9617 'load polymer, <link rel="import" href="' +
9618 'components/polymer/polymer.html">');
9619 };
9620 }
9621 });
9622
9623 })(window.Platform);
9624
9625 /*
9626 * Copyright 2012 The Polymer Authors. All rights reserved. 9560 * Copyright 2012 The Polymer Authors. All rights reserved.
9627 * Use of this source code is goverened by a BSD-style 9561 * Use of this source code is goverened by a BSD-style
9628 * license that can be found in the LICENSE file. 9562 * license that can be found in the LICENSE file.
9629 */ 9563 */
9630 9564
9631 (function(global) { 9565 (function(global) {
9632 9566
9633 var registrationsTable = new WeakMap(); 9567 var registrationsTable = new WeakMap();
9634 9568
9635 // We use setImmediate or postMessage for our future callback. 9569 // We use setImmediate or postMessage for our future callback.
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
10284 imp.addEventListener('error', loadedImport); 10218 imp.addEventListener('error', loadedImport);
10285 } 10219 }
10286 } 10220 }
10287 } else { 10221 } else {
10288 checkDone(); 10222 checkDone();
10289 } 10223 }
10290 } 10224 }
10291 10225
10292 // NOTE: test for native imports loading is based on explicitly watching 10226 // NOTE: test for native imports loading is based on explicitly watching
10293 // all imports (see below). 10227 // all imports (see below).
10228 // We cannot rely on this entirely without watching the entire document
10229 // for import links. For perf reasons, currently only head is watched.
10230 // Instead, we fallback to checking if the import property is available
10231 // and the document is not itself loading.
10294 function isImportLoaded(link) { 10232 function isImportLoaded(link) {
10295 return useNative ? link.__loaded : link.__importParsed; 10233 return useNative ? link.__loaded ||
10234 (link.import && link.import.readyState !== 'loading') :
10235 link.__importParsed;
10296 } 10236 }
10297 10237
10298 // TODO(sorvell): Workaround for 10238 // TODO(sorvell): Workaround for
10299 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=25007, should be removed when 10239 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=25007, should be removed when
10300 // this bug is addressed. 10240 // this bug is addressed.
10301 // (1) Install a mutation observer to see when HTMLImports have loaded 10241 // (1) Install a mutation observer to see when HTMLImports have loaded
10302 // (2) if this script is run during document load it will watch any existing 10242 // (2) if this script is run during document load it will watch any existing
10303 // imports for loading. 10243 // imports for loading.
10304 // 10244 //
10305 // NOTE: The workaround has restricted functionality: (1) it's only compatible 10245 // NOTE: The workaround has restricted functionality: (1) it's only compatible
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
10761 generateScriptDataUrl(scriptElt); 10701 generateScriptDataUrl(scriptElt);
10762 scope.currentScript = scriptElt; 10702 scope.currentScript = scriptElt;
10763 this.trackElement(script, function(e) { 10703 this.trackElement(script, function(e) {
10764 script.parentNode.removeChild(script); 10704 script.parentNode.removeChild(script);
10765 scope.currentScript = null; 10705 scope.currentScript = null;
10766 }); 10706 });
10767 this.addElementToDocument(script); 10707 this.addElementToDocument(script);
10768 }, 10708 },
10769 // determine the next element in the tree which should be parsed 10709 // determine the next element in the tree which should be parsed
10770 nextToParse: function() { 10710 nextToParse: function() {
10711 this._mayParse = [];
10771 return !this.parsingElement && this.nextToParseInDoc(mainDoc); 10712 return !this.parsingElement && this.nextToParseInDoc(mainDoc);
10772 }, 10713 },
10773 nextToParseInDoc: function(doc, link) { 10714 nextToParseInDoc: function(doc, link) {
10774 if (doc) { 10715 // use `marParse` list to avoid looping into the same document again
10716 // since it could cause an iloop.
10717 if (doc && this._mayParse.indexOf(doc) < 0) {
10718 this._mayParse.push(doc);
10775 var nodes = doc.querySelectorAll(this.parseSelectorsForNode(doc)); 10719 var nodes = doc.querySelectorAll(this.parseSelectorsForNode(doc));
10776 for (var i=0, l=nodes.length, p=0, n; (i<l) && (n=nodes[i]); i++) { 10720 for (var i=0, l=nodes.length, p=0, n; (i<l) && (n=nodes[i]); i++) {
10777 if (!this.isParsed(n)) { 10721 if (!this.isParsed(n)) {
10778 if (this.hasResource(n)) { 10722 if (this.hasResource(n)) {
10779 return nodeIsImport(n) ? this.nextToParseInDoc(n.import, n) : n; 10723 return nodeIsImport(n) ? this.nextToParseInDoc(n.import, n) : n;
10780 } else { 10724 } else {
10781 return; 10725 return;
10782 } 10726 }
10783 } 10727 }
10784 } 10728 }
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
11494 function observeDocument(doc) { 11438 function observeDocument(doc) {
11495 observe(doc); 11439 observe(doc);
11496 } 11440 }
11497 11441
11498 function upgradeDocument(doc) { 11442 function upgradeDocument(doc) {
11499 logFlags.dom && console.group('upgradeDocument: ', (doc.baseURI).split('/').po p()); 11443 logFlags.dom && console.group('upgradeDocument: ', (doc.baseURI).split('/').po p());
11500 addedNode(doc); 11444 addedNode(doc);
11501 logFlags.dom && console.groupEnd(); 11445 logFlags.dom && console.groupEnd();
11502 } 11446 }
11503 11447
11448 /*
11449 This method is intended to be called when the document tree (including imports)
11450 has pending custom elements to upgrade. It can be called multiple times and
11451 should do nothing if no elements are in need of upgrade.
11452
11453 Note that the import tree can consume itself and therefore special care
11454 must be taken to avoid recursion.
11455 */
11456 var upgradedDocuments;
11504 function upgradeDocumentTree(doc) { 11457 function upgradeDocumentTree(doc) {
11458 upgradedDocuments = [];
11459 _upgradeDocumentTree(doc);
11460 upgradedDocuments = null;
11461 }
11462
11463
11464 function _upgradeDocumentTree(doc) {
11505 doc = wrapIfNeeded(doc); 11465 doc = wrapIfNeeded(doc);
11466 if (upgradedDocuments.indexOf(doc) >= 0) {
11467 return;
11468 }
11469 upgradedDocuments.push(doc);
11506 //console.log('upgradeDocumentTree: ', (doc.baseURI).split('/').pop()); 11470 //console.log('upgradeDocumentTree: ', (doc.baseURI).split('/').pop());
11507 // upgrade contained imported documents 11471 // upgrade contained imported documents
11508 var imports = doc.querySelectorAll('link[rel=' + IMPORT_LINK_TYPE + ']'); 11472 var imports = doc.querySelectorAll('link[rel=' + IMPORT_LINK_TYPE + ']');
11509 for (var i=0, l=imports.length, n; (i<l) && (n=imports[i]); i++) { 11473 for (var i=0, l=imports.length, n; (i<l) && (n=imports[i]); i++) {
11510 if (n.import && n.import.__parsed) { 11474 if (n.import && n.import.__parsed) {
11511 upgradeDocumentTree(n.import); 11475 _upgradeDocumentTree(n.import);
11512 } 11476 }
11513 } 11477 }
11514 upgradeDocument(doc); 11478 upgradeDocument(doc);
11515 } 11479 }
11516 11480
11517 // exports 11481 // exports
11518 scope.IMPORT_LINK_TYPE = IMPORT_LINK_TYPE; 11482 scope.IMPORT_LINK_TYPE = IMPORT_LINK_TYPE;
11519 scope.watchShadow = watchShadow; 11483 scope.watchShadow = watchShadow;
11520 scope.upgradeDocumentTree = upgradeDocumentTree; 11484 scope.upgradeDocumentTree = upgradeDocumentTree;
11521 scope.upgradeAll = addedNode; 11485 scope.upgradeAll = addedNode;
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
12184 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. 12148 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
12185 * This code may only be used under the BSD style license found at http://polyme r.github.io/LICENSE.txt 12149 * This code may only be used under the BSD style license found at http://polyme r.github.io/LICENSE.txt
12186 * The complete set of authors may be found at http://polymer.github.io/AUTHORS. txt 12150 * The complete set of authors may be found at http://polymer.github.io/AUTHORS. txt
12187 * The complete set of contributors may be found at http://polymer.github.io/CON TRIBUTORS.txt 12151 * The complete set of contributors may be found at http://polymer.github.io/CON TRIBUTORS.txt
12188 * Code distributed by Google as part of the polymer project is also 12152 * Code distributed by Google as part of the polymer project is also
12189 * subject to an additional IP rights grant found at http://polymer.github.io/PA TENTS.txt 12153 * subject to an additional IP rights grant found at http://polymer.github.io/PA TENTS.txt
12190 */ 12154 */
12191 12155
12192 (function(scope) { 12156 (function(scope) {
12193 12157
12194 // TODO(sorvell): It's desireable to provide a default stylesheet 12158 'use strict';
12159
12160 // polyfill performance.now
12161
12162 if (!window.performance) {
12163 var start = Date.now();
12164 // only at millisecond precision
12165 window.performance = {now: function(){ return Date.now() - start }};
12166 }
12167
12168 // polyfill for requestAnimationFrame
12169
12170 if (!window.requestAnimationFrame) {
12171 window.requestAnimationFrame = (function() {
12172 var nativeRaf = window.webkitRequestAnimationFrame ||
12173 window.mozRequestAnimationFrame;
12174
12175 return nativeRaf ?
12176 function(callback) {
12177 return nativeRaf(function() {
12178 callback(performance.now());
12179 });
12180 } :
12181 function( callback ){
12182 return window.setTimeout(callback, 1000 / 60);
12183 };
12184 })();
12185 }
12186
12187 if (!window.cancelAnimationFrame) {
12188 window.cancelAnimationFrame = (function() {
12189 return window.webkitCancelAnimationFrame ||
12190 window.mozCancelAnimationFrame ||
12191 function(id) {
12192 clearTimeout(id);
12193 };
12194 })();
12195 }
12196
12197 // Make a stub for Polymer() for polyfill purposes; under the HTMLImports
12198 // polyfill, scripts in the main document run before imports. That means
12199 // if (1) polymer is imported and (2) Polymer() is called in the main document
12200 // in a script after the import, 2 occurs before 1. We correct this here
12201 // by specfiically patching Polymer(); this is not necessary under native
12202 // HTMLImports.
12203 var elementDeclarations = [];
12204
12205 var polymerStub = function(name, dictionary) {
12206 if ((typeof name !== 'string') && (arguments.length === 1)) {
12207 Array.prototype.push.call(arguments, document._currentScript);
12208 }
12209 elementDeclarations.push(arguments);
12210 };
12211 window.Polymer = polymerStub;
12212
12213 // deliver queued delcarations
12214 scope.consumeDeclarations = function(callback) {
12215 scope.consumeDeclarations = function() {
12216 throw 'Possible attempt to load Polymer twice';
12217 };
12218 if (callback) {
12219 callback(elementDeclarations);
12220 }
12221 elementDeclarations = null;
12222 };
12223
12224 function installPolymerWarning() {
12225 if (window.Polymer === polymerStub) {
12226 window.Polymer = function() {
12227 throw new Error('You tried to use polymer without loading it first. To ' +
12228 'load polymer, <link rel="import" href="' +
12229 'components/polymer/polymer.html">');
12230 };
12231 }
12232 }
12233
12234 // Once DOMContent has loaded, any main document scripts that depend on
12235 // Polymer() should have run. Calling Polymer() now is an error until
12236 // polymer is imported.
12237 if (HTMLImports.useNative) {
12238 installPolymerWarning();
12239 } else {
12240 addEventListener('DOMContentLoaded', installPolymerWarning);
12241 }
12242
12243 })(window.Platform);
12244
12245 /*
12246 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
12247 * This code may only be used under the BSD style license found at http://polyme r.github.io/LICENSE.txt
12248 * The complete set of authors may be found at http://polymer.github.io/AUTHORS. txt
12249 * The complete set of contributors may be found at http://polymer.github.io/CON TRIBUTORS.txt
12250 * Code distributed by Google as part of the polymer project is also
12251 * subject to an additional IP rights grant found at http://polymer.github.io/PA TENTS.txt
12252 */
12253
12254 (function(scope) {
12255
12256 // It's desireable to provide a default stylesheet
12195 // that's convenient for styling unresolved elements, but 12257 // that's convenient for styling unresolved elements, but
12196 // it's cumbersome to have to include this manually in every page. 12258 // it's cumbersome to have to include this manually in every page.
12197 // It would make sense to put inside some HTMLImport but 12259 // It would make sense to put inside some HTMLImport but
12198 // the HTMLImports polyfill does not allow loading of stylesheets 12260 // the HTMLImports polyfill does not allow loading of stylesheets
12199 // that block rendering. Therefore this injection is tolerated here. 12261 // that block rendering. Therefore this injection is tolerated here.
12200 12262 //
12263 // NOTE: position: relative fixes IE's failure to inherit opacity
12264 // when a child is not statically positioned.
12201 var style = document.createElement('style'); 12265 var style = document.createElement('style');
12202 style.textContent = '' 12266 style.textContent = ''
12203 + 'body {' 12267 + 'body {'
12204 + 'transition: opacity ease-in 0.2s;' 12268 + 'transition: opacity ease-in 0.2s;'
12205 + ' } \n' 12269 + ' } \n'
12206 + 'body[unresolved] {' 12270 + 'body[unresolved] {'
12207 + 'opacity: 0; display: block; overflow: hidden;' 12271 + 'opacity: 0; display: block; overflow: hidden; position: relative;'
12208 + ' } \n' 12272 + ' } \n'
12209 ; 12273 ;
12210 var head = document.querySelector('head'); 12274 var head = document.querySelector('head');
12211 head.insertBefore(style, head.firstChild); 12275 head.insertBefore(style, head.firstChild);
12212 12276
12213 })(Platform); 12277 })(Platform);
12214 12278
12215 /* 12279 /*
12216 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. 12280 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
12217 * This code may only be used under the BSD style license found at http://polyme r.github.io/LICENSE.txt 12281 * This code may only be used under the BSD style license found at http://polyme r.github.io/LICENSE.txt
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
12266 // exports 12330 // exports
12267 12331
12268 scope.marshal = marshal; 12332 scope.marshal = marshal;
12269 // `module` confuses commonjs detectors 12333 // `module` confuses commonjs detectors
12270 scope.modularize = module; 12334 scope.modularize = module;
12271 scope.using = using; 12335 scope.using = using;
12272 12336
12273 })(window); 12337 })(window);
12274 12338
12275 //# sourceMappingURL=platform.concat.js.map 12339 //# 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