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

Side by Side Diff: pkg/polymer/lib/src/js/polymer/polymer.concat.js

Issue 420673002: Roll polymer packages to version 0.3.4 (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
OLDNEW
1 /** 1 /**
2 * @license 2 * @license
3 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. 3 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
4 * This code may only be used under the BSD style license found at http://polyme r.github.io/LICENSE.txt 4 * This code may only be used under the BSD style license found at http://polyme r.github.io/LICENSE.txt
5 * The complete set of authors may be found at http://polymer.github.io/AUTHORS. txt 5 * The complete set of authors may be found at http://polymer.github.io/AUTHORS. txt
6 * The complete set of contributors may be found at http://polymer.github.io/CON TRIBUTORS.txt 6 * The complete set of contributors may be found at http://polymer.github.io/CON TRIBUTORS.txt
7 * Code distributed by Google as part of the polymer project is also 7 * Code distributed by Google as part of the polymer project is also
8 * subject to an additional IP rights grant found at http://polymer.github.io/PA TENTS.txt 8 * subject to an additional IP rights grant found at http://polymer.github.io/PA TENTS.txt
9 */ 9 */
10 window.PolymerGestures = { 10 window.PolymerGestures = {
(...skipping 3635 matching lines...) Expand 10 before | Expand all | Expand 10 after
3646 })(this); 3646 })(this);
3647 3647
3648 /* 3648 /*
3649 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. 3649 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
3650 * This code may only be used under the BSD style license found at http://polyme r.github.io/LICENSE.txt 3650 * This code may only be used under the BSD style license found at http://polyme r.github.io/LICENSE.txt
3651 * The complete set of authors may be found at http://polymer.github.io/AUTHORS. txt 3651 * The complete set of authors may be found at http://polymer.github.io/AUTHORS. txt
3652 * The complete set of contributors may be found at http://polymer.github.io/CON TRIBUTORS.txt 3652 * The complete set of contributors may be found at http://polymer.github.io/CON TRIBUTORS.txt
3653 * Code distributed by Google as part of the polymer project is also 3653 * Code distributed by Google as part of the polymer project is also
3654 * subject to an additional IP rights grant found at http://polymer.github.io/PA TENTS.txt 3654 * subject to an additional IP rights grant found at http://polymer.github.io/PA TENTS.txt
3655 */ 3655 */
3656 Polymer = {
3657 version: '0.3.3-0e73963'
3658 };
3659
3660 /*
3661 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
3662 * This code may only be used under the BSD style license found at http://polyme r.github.io/LICENSE.txt
3663 * The complete set of authors may be found at http://polymer.github.io/AUTHORS. txt
3664 * The complete set of contributors may be found at http://polymer.github.io/CON TRIBUTORS.txt
3665 * Code distributed by Google as part of the polymer project is also
3666 * subject to an additional IP rights grant found at http://polymer.github.io/PA TENTS.txt
3667 */
3668 3656
3669 // TODO(sorvell): this ensures Polymer is an object and not a function 3657 // TODO(sorvell): this ensures Polymer is an object and not a function
3670 // Platform is currently defining it as a function to allow for async loading 3658 // Platform is currently defining it as a function to allow for async loading
3671 // of polymer; once we refine the loading process this likely goes away. 3659 // of polymer; once we refine the loading process this likely goes away.
3672 if (typeof window.Polymer === 'function') { 3660 if (typeof window.Polymer === 'function') {
3673 Polymer = {}; 3661 Polymer = {};
3674 } 3662 }
3675 3663
3676 3664
3677 /* 3665 /*
(...skipping 1348 matching lines...) Expand 10 before | Expand all | Expand 10 after
5026 if (!scope) { 5014 if (!scope) {
5027 return; 5015 return;
5028 } 5016 }
5029 if (window.ShadowDOMPolyfill) { 5017 if (window.ShadowDOMPolyfill) {
5030 cssText = shimCssText(cssText, scope.host); 5018 cssText = shimCssText(cssText, scope.host);
5031 } 5019 }
5032 var style = this.element.cssTextToScopeStyle(cssText, 5020 var style = this.element.cssTextToScopeStyle(cssText,
5033 STYLE_CONTROLLER_SCOPE); 5021 STYLE_CONTROLLER_SCOPE);
5034 Polymer.applyStyleToScope(style, scope); 5022 Polymer.applyStyleToScope(style, scope);
5035 // cache that this style has been applied 5023 // cache that this style has been applied
5036 scope._scopeStyles[this.localName + name] = true; 5024 this.styleCacheForScope(scope)[this.localName + name] = true;
5037 }, 5025 },
5038 findStyleScope: function(node) { 5026 findStyleScope: function(node) {
5039 // find the shadow root that contains this element 5027 // find the shadow root that contains this element
5040 var n = node || this; 5028 var n = node || this;
5041 while (n.parentNode) { 5029 while (n.parentNode) {
5042 n = n.parentNode; 5030 n = n.parentNode;
5043 } 5031 }
5044 return n; 5032 return n;
5045 }, 5033 },
5046 scopeHasNamedStyle: function(scope, name) { 5034 scopeHasNamedStyle: function(scope, name) {
5047 scope._scopeStyles = scope._scopeStyles || {}; 5035 var cache = this.styleCacheForScope(scope);
5048 return scope._scopeStyles[name]; 5036 return cache[name];
5037 },
5038 styleCacheForScope: function(scope) {
5039 if (window.ShadowDOMPolyfill) {
5040 var scopeName = scope.host ? scope.host.localName : scope.localName;
5041 return polyfillScopeStyleCache[scopeName] || (polyfillScopeStyleCache[sc opeName] = {});
5042 } else {
5043 return scope._scopeStyles = (scope._scopeStyles || {});
5044 }
5049 } 5045 }
5050 }; 5046 };
5047
5048 var polyfillScopeStyleCache = {};
5051 5049
5052 // NOTE: use raw prototype traversal so that we ensure correct traversal 5050 // NOTE: use raw prototype traversal so that we ensure correct traversal
5053 // on platforms where the protoype chain is simulated via __proto__ (IE10) 5051 // on platforms where the protoype chain is simulated via __proto__ (IE10)
5054 function getPrototypeOf(prototype) { 5052 function getPrototypeOf(prototype) {
5055 return prototype.__proto__; 5053 return prototype.__proto__;
5056 } 5054 }
5057 5055
5058 function shimCssText(cssText, host) { 5056 function shimCssText(cssText, host) {
5059 var name = '', is = false; 5057 var name = '', is = false;
5060 if (host) { 5058 if (host) {
(...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after
6164 upgrade ordering as long as they query the dom tree 1 task after 6162 upgrade ordering as long as they query the dom tree 1 task after
6165 upgrade (aka domReady). This is a performance tradeoff. On the one hand, 6163 upgrade (aka domReady). This is a performance tradeoff. On the one hand,
6166 elements that could register while imports are loading are prevented from 6164 elements that could register while imports are loading are prevented from
6167 doing so. On the other, grouping upgrades into a single task means less 6165 doing so. On the other, grouping upgrades into a single task means less
6168 incremental work (for example style recalcs), Also, we can ensure the 6166 incremental work (for example style recalcs), Also, we can ensure the
6169 document is in a known state at the single quantum of time when 6167 document is in a known state at the single quantum of time when
6170 elements upgrade. 6168 elements upgrade.
6171 6169
6172 */ 6170 */
6173 var queue = { 6171 var queue = {
6172
6174 // tell the queue to wait for an element to be ready 6173 // tell the queue to wait for an element to be ready
6175 wait: function(element, check, go) { 6174 wait: function(element) {
6176 var shouldAdd = (this.indexOf(element) === -1 && 6175 if (!element.__queue) {
6177 flushQueue.indexOf(element) === -1); 6176 element.__queue = {};
6177 elements.push(element);
6178 }
6179 },
6180
6181 // enqueue an element to the next spot in the queue.
6182 enqueue: function(element, check, go) {
6183 var shouldAdd = element.__queue && !element.__queue.check;
6178 if (shouldAdd) { 6184 if (shouldAdd) {
6179 this.add(element); 6185 queueForElement(element).push(element);
6180 element.__check = check; 6186 element.__queue.check = check;
6181 element.__go = go; 6187 element.__queue.go = go;
6182 } 6188 }
6183 return (this.indexOf(element) !== 0); 6189 return (this.indexOf(element) !== 0);
6184 }, 6190 },
6185 add: function(element) { 6191
6186 //console.log('queueing', element.name);
6187 queueForElement(element).push(element);
6188 },
6189 indexOf: function(element) { 6192 indexOf: function(element) {
6190 var i = queueForElement(element).indexOf(element); 6193 var i = queueForElement(element).indexOf(element);
6191 if (i >= 0 && document.contains(element)) { 6194 if (i >= 0 && document.contains(element)) {
6192 i += (HTMLImports.useNative || HTMLImports.ready) ? 6195 i += (HTMLImports.useNative || HTMLImports.ready) ?
6193 importQueue.length : 1e9; 6196 importQueue.length : 1e9;
6194 } 6197 }
6195 return i; 6198 return i;
6196 }, 6199 },
6200
6197 // tell the queue an element is ready to be registered 6201 // tell the queue an element is ready to be registered
6198 go: function(element) { 6202 go: function(element) {
6199 var readied = this.remove(element); 6203 var readied = this.remove(element);
6200 if (readied) { 6204 if (readied) {
6205 element.__queue.flushable = true;
6201 this.addToFlushQueue(readied); 6206 this.addToFlushQueue(readied);
6202 this.check(); 6207 this.check();
6203 } 6208 }
6204 }, 6209 },
6210
6205 remove: function(element) { 6211 remove: function(element) {
6206 var i = this.indexOf(element); 6212 var i = this.indexOf(element);
6207 if (i !== 0) { 6213 if (i !== 0) {
6208 //console.warn('queue order wrong', i); 6214 //console.warn('queue order wrong', i);
6209 return; 6215 return;
6210 } 6216 }
6211 return queueForElement(element).shift(); 6217 return queueForElement(element).shift();
6212 }, 6218 },
6219
6213 check: function() { 6220 check: function() {
6214 // next 6221 // next
6215 var element = this.nextElement(); 6222 var element = this.nextElement();
6216 if (element) { 6223 if (element) {
6217 element.__check.call(element); 6224 element.__queue.check.call(element);
6218 } 6225 }
6219 if (this.canReady()) { 6226 if (this.canReady()) {
6220 this.ready(); 6227 this.ready();
6221 return true; 6228 return true;
6222 } 6229 }
6223 }, 6230 },
6231
6224 nextElement: function() { 6232 nextElement: function() {
6225 return nextQueued(); 6233 return nextQueued();
6226 }, 6234 },
6235
6227 canReady: function() { 6236 canReady: function() {
6228 return !this.waitToReady && this.isEmpty(); 6237 return !this.waitToReady && this.isEmpty();
6229 }, 6238 },
6239
6230 isEmpty: function() { 6240 isEmpty: function() {
6231 return !importQueue.length && !mainQueue.length; 6241 for (var i=0, l=elements.length, e; (i<l) &&
6242 (e=elements[i]); i++) {
6243 if (e.__queue && !e.__queue.flushable) {
6244 return;
6245 }
6246 }
6247 return true;
6232 }, 6248 },
6249
6233 addToFlushQueue: function(element) { 6250 addToFlushQueue: function(element) {
6234 flushQueue.push(element); 6251 flushQueue.push(element);
6235 }, 6252 },
6253
6236 flush: function() { 6254 flush: function() {
6255 // prevent re-entrance
6256 if (this.flushing) {
6257 return;
6258 }
6259 if (flushQueue.length) {
6260 console.warn('flushing %s elements', flushQueue.length);
6261 }
6262 this.flushing = true;
6237 var element; 6263 var element;
6238 while (flushQueue.length) { 6264 while (flushQueue.length) {
6239 element = flushQueue.shift(); 6265 element = flushQueue.shift();
6240 element.__go.call(element); 6266 element.__queue.go.call(element);
6241 element.__check = element.__go = null; 6267 element.__queue = null;
6242 } 6268 }
6269 this.flushing = false;
6243 }, 6270 },
6271
6244 ready: function() { 6272 ready: function() {
6245 this.flush(); 6273 this.flush();
6246 // TODO(sorvell): As an optimization, turn off CE polyfill upgrading 6274 // TODO(sorvell): As an optimization, turn off CE polyfill upgrading
6247 // while registering. This way we avoid having to upgrade each document 6275 // while registering. This way we avoid having to upgrade each document
6248 // piecemeal per registration and can instead register all elements 6276 // piecemeal per registration and can instead register all elements
6249 // and upgrade once in a batch. Without this optimization, upgrade time 6277 // and upgrade once in a batch. Without this optimization, upgrade time
6250 // degrades significantly when SD polyfill is used. This is mainly because 6278 // degrades significantly when SD polyfill is used. This is mainly because
6251 // querying the document tree for elements is slow under the SD polyfill. 6279 // querying the document tree for elements is slow under the SD polyfill.
6252 if (CustomElements.ready === false) { 6280 if (CustomElements.ready === false) {
6253 CustomElements.upgradeDocumentTree(document); 6281 CustomElements.upgradeDocumentTree(document);
6254 CustomElements.ready = true; 6282 CustomElements.ready = true;
6255 } 6283 }
6256 Platform.flush(); 6284 Platform.flush();
6257 requestAnimationFrame(this.flushReadyCallbacks); 6285 requestAnimationFrame(this.flushReadyCallbacks);
6258 }, 6286 },
6287
6259 addReadyCallback: function(callback) { 6288 addReadyCallback: function(callback) {
6260 if (callback) { 6289 if (callback) {
6261 readyCallbacks.push(callback); 6290 readyCallbacks.push(callback);
6262 } 6291 }
6263 }, 6292 },
6293
6264 flushReadyCallbacks: function() { 6294 flushReadyCallbacks: function() {
6265 if (readyCallbacks) { 6295 if (readyCallbacks) {
6266 var fn; 6296 var fn;
6267 while (readyCallbacks.length) { 6297 while (readyCallbacks.length) {
6268 fn = readyCallbacks.shift(); 6298 fn = readyCallbacks.shift();
6269 fn(); 6299 fn();
6270 } 6300 }
6271 } 6301 }
6272 }, 6302 },
6303
6273 waitToReady: true 6304 waitToReady: true
6305
6274 }; 6306 };
6275 6307
6308 var elements = [];
6276 var flushQueue = []; 6309 var flushQueue = [];
6277
6278 var importQueue = []; 6310 var importQueue = [];
6279 var mainQueue = []; 6311 var mainQueue = [];
6280 var readyCallbacks = []; 6312 var readyCallbacks = [];
6281 6313
6282 function queueForElement(element) { 6314 function queueForElement(element) {
6283 return document.contains(element) ? mainQueue : importQueue; 6315 return document.contains(element) ? mainQueue : importQueue;
6284 } 6316 }
6285 6317
6286 function nextQueued() { 6318 function nextQueued() {
6287 return importQueue.length ? importQueue[0] : mainQueue[0]; 6319 return importQueue.length ? importQueue[0] : mainQueue[0];
6288 } 6320 }
6289 6321
6290 var polymerReadied = false; 6322 var polymerReadied = false;
6291 6323
6292 document.addEventListener('WebComponentsReady', function() { 6324 document.addEventListener('WebComponentsReady', function() {
6293 CustomElements.ready = false; 6325 CustomElements.ready = false;
6294 }); 6326 });
6295 6327
6296 function whenPolymerReady(callback) { 6328 function whenPolymerReady(callback) {
6297 queue.waitToReady = true; 6329 queue.waitToReady = true;
6298 CustomElements.ready = false; 6330 CustomElements.ready = false;
6299 HTMLImports.whenImportsReady(function() { 6331 HTMLImports.whenImportsReady(function() {
6300 queue.addReadyCallback(callback); 6332 queue.addReadyCallback(callback);
6301 queue.waitToReady = false; 6333 queue.waitToReady = false;
6302 queue.check(); 6334 queue.check();
6303 }); 6335 });
6304 } 6336 }
6305 6337
6306 // exports 6338 // exports
6339 scope.elements = elements;
6307 scope.queue = queue; 6340 scope.queue = queue;
6308 scope.whenPolymerReady = whenPolymerReady; 6341 scope.whenReady = scope.whenPolymerReady = whenPolymerReady;
6309 })(Polymer); 6342 })(Polymer);
6310 6343
6311 /* 6344 /*
6312 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. 6345 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
6313 * This code may only be used under the BSD style license found at http://polyme r.github.io/LICENSE.txt 6346 * This code may only be used under the BSD style license found at http://polyme r.github.io/LICENSE.txt
6314 * The complete set of authors may be found at http://polymer.github.io/AUTHORS. txt 6347 * The complete set of authors may be found at http://polymer.github.io/AUTHORS. txt
6315 * The complete set of contributors may be found at http://polymer.github.io/CON TRIBUTORS.txt 6348 * The complete set of contributors may be found at http://polymer.github.io/CON TRIBUTORS.txt
6316 * Code distributed by Google as part of the polymer project is also 6349 * Code distributed by Google as part of the polymer project is also
6317 * subject to an additional IP rights grant found at http://polymer.github.io/PA TENTS.txt 6350 * subject to an additional IP rights grant found at http://polymer.github.io/PA TENTS.txt
6318 */ 6351 */
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
6378 createdCallback: function() { 6411 createdCallback: function() {
6379 if (this.getAttribute('name')) { 6412 if (this.getAttribute('name')) {
6380 this.init(); 6413 this.init();
6381 } 6414 }
6382 }, 6415 },
6383 6416
6384 init: function() { 6417 init: function() {
6385 // fetch declared values 6418 // fetch declared values
6386 this.name = this.getAttribute('name'); 6419 this.name = this.getAttribute('name');
6387 this.extends = this.getAttribute('extends'); 6420 this.extends = this.getAttribute('extends');
6421 queue.wait(this);
6388 // initiate any async resource fetches 6422 // initiate any async resource fetches
6389 this.loadResources(); 6423 this.loadResources();
6390 // register when all constraints are met 6424 // register when all constraints are met
6391 this.registerWhenReady(); 6425 this.registerWhenReady();
6392 }, 6426 },
6393 6427
6428 // TODO(sorvell): we currently queue in the order the prototypes are
6429 // registered, but we should queue in the order that polymer-elements
6430 // are registered. We are currently blocked from doing this based on
6431 // crbug.com/395686.
6394 registerWhenReady: function() { 6432 registerWhenReady: function() {
6395 if (this.registered 6433 if (this.registered
6396 || this.waitingForPrototype(this.name) 6434 || this.waitingForPrototype(this.name)
6397 || this.waitingForQueue() 6435 || this.waitingForQueue()
6398 || this.waitingForResources()) { 6436 || this.waitingForResources()) {
6399 return; 6437 return;
6400 } 6438 }
6401 // TODO(sorvell): ends up calling '_register' by virtue
6402 // of `waitingForQueue` (see below)
6403 queue.go(this); 6439 queue.go(this);
6404 }, 6440 },
6405 6441
6406 // TODO(sorvell): refactor, this method is private-ish, but it's being
6407 // called by the queue object.
6408 _register: function() { 6442 _register: function() {
6409 //console.log('registering', this.name); 6443 //console.log('registering', this.name);
6410 //console.group('registering', this.name);
6411 // warn if extending from a custom element not registered via Polymer 6444 // warn if extending from a custom element not registered via Polymer
6412 if (isCustomTag(this.extends) && !isRegistered(this.extends)) { 6445 if (isCustomTag(this.extends) && !isRegistered(this.extends)) {
6413 console.warn('%s is attempting to extend %s, an unregistered element ' + 6446 console.warn('%s is attempting to extend %s, an unregistered element ' +
6414 'or one that was not registered with Polymer.', this.name, 6447 'or one that was not registered with Polymer.', this.name,
6415 this.extends); 6448 this.extends);
6416 } 6449 }
6417 this.register(this.name, this.extends); 6450 this.register(this.name, this.extends);
6418 this.registered = true; 6451 this.registered = true;
6419 //console.groupEnd();
6420 }, 6452 },
6421 6453
6422 waitingForPrototype: function(name) { 6454 waitingForPrototype: function(name) {
6423 if (!getRegisteredPrototype(name)) { 6455 if (!getRegisteredPrototype(name)) {
6424 // then wait for a prototype 6456 // then wait for a prototype
6425 waitingForPrototype(name, this); 6457 waitingForPrototype(name, this);
6426 // emulate script if user is not supplying one 6458 // emulate script if user is not supplying one
6427 this.handleNoScript(name); 6459 this.handleNoScript(name);
6428 // prototype not ready yet 6460 // prototype not ready yet
6429 return true; 6461 return true;
6430 } 6462 }
6431 }, 6463 },
6432 6464
6433 handleNoScript: function(name) { 6465 handleNoScript: function(name) {
6434 // if explicitly marked as 'noscript' 6466 // if explicitly marked as 'noscript'
6435 if (this.hasAttribute('noscript') && !this.noscript) { 6467 if (this.hasAttribute('noscript') && !this.noscript) {
6436 this.noscript = true; 6468 this.noscript = true;
6437 // TODO(sorvell): CustomElements polyfill awareness: 6469 // imperative element registration
6438 // noscript elements should upgrade in logical order 6470 Polymer(name);
6439 // script injection ensures this under native custom elements;
6440 // under imports + ce polyfills, scripts run before upgrades.
6441 // dependencies should be ready at upgrade time so register
6442 // prototype at this time.
6443 if (window.CustomElements && !CustomElements.useNative) {
6444 Polymer(name);
6445 } else {
6446 var script = document.createElement('script');
6447 script.textContent = 'Polymer(\'' + name + '\');';
6448 this.appendChild(script);
6449 }
6450 } 6471 }
6451 }, 6472 },
6452 6473
6453 waitingForResources: function() { 6474 waitingForResources: function() {
6454 return this._needsResources; 6475 return this._needsResources;
6455 }, 6476 },
6456 6477
6457 // NOTE: Elements must be queued in proper order for inheritance/composition 6478 // NOTE: Elements must be queued in proper order for inheritance/composition
6458 // dependency resolution. Previously this was enforced for inheritance, 6479 // dependency resolution. Previously this was enforced for inheritance,
6459 // and by rule for composition. It's now entirely by rule. 6480 // and by rule for composition. It's now entirely by rule.
6460 waitingForQueue: function() { 6481 waitingForQueue: function() {
6461 return queue.wait(this, this.registerWhenReady, this._register); 6482 return queue.enqueue(this, this.registerWhenReady, this._register);
6462 }, 6483 },
6463 6484
6464 loadResources: function() { 6485 loadResources: function() {
6465 this._needsResources = true; 6486 this._needsResources = true;
6466 this.loadStyles(function() { 6487 this.loadStyles(function() {
6467 this._needsResources = false; 6488 this._needsResources = false;
6468 this.registerWhenReady(); 6489 this.registerWhenReady();
6469 }.bind(this)); 6490 }.bind(this));
6470 } 6491 }
6471 6492
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
6582 prepareBinding.call(syntax, pathString, name, node); 6603 prepareBinding.call(syntax, pathString, name, node);
6583 }; 6604 };
6584 return syntax; 6605 return syntax;
6585 } 6606 }
6586 6607
6587 }); 6608 });
6588 6609
6589 })(); 6610 })();
6590 6611
6591 //# sourceMappingURL=polymer.concat.js.map 6612 //# sourceMappingURL=polymer.concat.js.map
OLDNEW
« no previous file with comments | « pkg/polymer/lib/src/js/polymer/polymer.js ('k') | pkg/polymer/lib/src/js/polymer/polymer.concat.js.map » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698