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

Side by Side Diff: third_party/polymer/v1_0/components-chromium/polymer/polymer-extracted.js

Issue 2717403003: WebUI: Roll Polymer 1.6.1-> 1.8.1 (Closed)
Patch Set: Undo paper-ripple changes in reproduce.sh Created 3 years, 9 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
OLDNEW
1 (function () {
1 Polymer.nar = []; 2 Polymer.nar = [];
3 var disableUpgradeEnabled = Polymer.Settings.disableUpgradeEnabled;
2 Polymer.Annotations = { 4 Polymer.Annotations = {
3 parseAnnotations: function (template) { 5 parseAnnotations: function (template, stripWhiteSpace) {
4 var list = []; 6 var list = [];
5 var content = template._content || template.content; 7 var content = template._content || template.content;
6 this._parseNodeAnnotations(content, list, template.hasAttribute('strip-whitespac e')); 8 this._parseNodeAnnotations(content, list, stripWhiteSpace || template.hasAttribu te('strip-whitespace'));
7 return list; 9 return list;
8 }, 10 },
9 _parseNodeAnnotations: function (node, list, stripWhiteSpace) { 11 _parseNodeAnnotations: function (node, list, stripWhiteSpace) {
10 return node.nodeType === Node.TEXT_NODE ? this._parseTextNodeAnnotation(node, li st) : this._parseElementAnnotations(node, list, stripWhiteSpace); 12 return node.nodeType === Node.TEXT_NODE ? this._parseTextNodeAnnotation(node, li st) : this._parseElementAnnotations(node, list, stripWhiteSpace);
11 }, 13 },
12 _bindingRegex: function () { 14 _bindingRegex: function () {
13 var IDENT = '(?:' + '[a-zA-Z_$][\\w.:$\\-*]*' + ')'; 15 var IDENT = '(?:' + '[a-zA-Z_$][\\w.:$\\-*]*' + ')';
14 var NUMBER = '(?:' + '[-+]?[0-9]*\\.?[0-9]+(?:[eE][-+]?[0-9]+)?' + ')'; 16 var NUMBER = '(?:' + '[-+]?[0-9]*\\.?[0-9]+(?:[eE][-+]?[0-9]+)?' + ')';
15 var SQUOTE_STRING = '(?:' + '\'(?:[^\'\\\\]|\\\\.)*\'' + ')'; 17 var SQUOTE_STRING = '(?:' + '\'(?:[^\'\\\\]|\\\\.)*\'' + ')';
16 var DQUOTE_STRING = '(?:' + '"(?:[^"\\\\]|\\\\.)*"' + ')'; 18 var DQUOTE_STRING = '(?:' + '"(?:[^"\\\\]|\\\\.)*"' + ')';
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 } 109 }
108 return annote; 110 return annote;
109 }, 111 },
110 _parseChildNodesAnnotations: function (root, annote, list, stripWhiteSpace) { 112 _parseChildNodesAnnotations: function (root, annote, list, stripWhiteSpace) {
111 if (root.firstChild) { 113 if (root.firstChild) {
112 var node = root.firstChild; 114 var node = root.firstChild;
113 var i = 0; 115 var i = 0;
114 while (node) { 116 while (node) {
115 var next = node.nextSibling; 117 var next = node.nextSibling;
116 if (node.localName === 'template' && !node.hasAttribute('preserve-content')) { 118 if (node.localName === 'template' && !node.hasAttribute('preserve-content')) {
117 this._parseTemplate(node, i, list, annote); 119 this._parseTemplate(node, i, list, annote, stripWhiteSpace);
120 }
121 if (node.localName == 'slot') {
122 node = this._replaceSlotWithContent(node);
118 } 123 }
119 if (node.nodeType === Node.TEXT_NODE) { 124 if (node.nodeType === Node.TEXT_NODE) {
120 var n = next; 125 var n = next;
121 while (n && n.nodeType === Node.TEXT_NODE) { 126 while (n && n.nodeType === Node.TEXT_NODE) {
122 node.textContent += n.textContent; 127 node.textContent += n.textContent;
123 next = n.nextSibling; 128 next = n.nextSibling;
124 root.removeChild(n); 129 root.removeChild(n);
125 n = next; 130 n = next;
126 } 131 }
127 if (stripWhiteSpace && !node.textContent.trim()) { 132 if (stripWhiteSpace && !node.textContent.trim()) {
128 root.removeChild(node); 133 root.removeChild(node);
129 i--; 134 i--;
130 } 135 }
131 } 136 }
132 if (node.parentNode) { 137 if (node.parentNode) {
133 var childAnnotation = this._parseNodeAnnotations(node, list, stripWhiteSpace); 138 var childAnnotation = this._parseNodeAnnotations(node, list, stripWhiteSpace);
134 if (childAnnotation) { 139 if (childAnnotation) {
135 childAnnotation.parent = annote; 140 childAnnotation.parent = annote;
136 childAnnotation.index = i; 141 childAnnotation.index = i;
137 } 142 }
138 } 143 }
139 node = next; 144 node = next;
140 i++; 145 i++;
141 } 146 }
142 } 147 }
143 }, 148 },
144 _parseTemplate: function (node, index, list, parent) { 149 _replaceSlotWithContent: function (slot) {
150 var content = slot.ownerDocument.createElement('content');
151 while (slot.firstChild) {
152 content.appendChild(slot.firstChild);
153 }
154 var attrs = slot.attributes;
155 for (var i = 0; i < attrs.length; i++) {
156 var attr = attrs[i];
157 content.setAttribute(attr.name, attr.value);
158 }
159 var name = slot.getAttribute('name');
160 if (name) {
161 content.setAttribute('select', '[slot=\'' + name + '\']');
162 }
163 slot.parentNode.replaceChild(content, slot);
164 return content;
165 },
166 _parseTemplate: function (node, index, list, parent, stripWhiteSpace) {
145 var content = document.createDocumentFragment(); 167 var content = document.createDocumentFragment();
146 content._notes = this.parseAnnotations(node); 168 content._notes = this.parseAnnotations(node, stripWhiteSpace);
147 content.appendChild(node.content); 169 content.appendChild(node.content);
148 list.push({ 170 list.push({
149 bindings: Polymer.nar, 171 bindings: Polymer.nar,
150 events: Polymer.nar, 172 events: Polymer.nar,
151 templateContent: content, 173 templateContent: content,
152 parent: parent, 174 parent: parent,
153 index: index 175 index: index
154 }); 176 });
155 }, 177 },
156 _parseNodeAttributeAnnotations: function (node, annotation) { 178 _parseNodeAttributeAnnotations: function (node, annotation) {
(...skipping 24 matching lines...) Expand all
181 name = name.slice(0, -1); 203 name = name.slice(0, -1);
182 kind = 'attribute'; 204 kind = 'attribute';
183 } 205 }
184 var literal = this._literalFromParts(parts); 206 var literal = this._literalFromParts(parts);
185 if (literal && kind == 'attribute') { 207 if (literal && kind == 'attribute') {
186 node.setAttribute(name, literal); 208 node.setAttribute(name, literal);
187 } 209 }
188 if (node.localName === 'input' && origName === 'value') { 210 if (node.localName === 'input' && origName === 'value') {
189 node.setAttribute(origName, ''); 211 node.setAttribute(origName, '');
190 } 212 }
213 if (disableUpgradeEnabled && origName === 'disable-upgrade$') {
214 node.setAttribute(name, '');
215 }
191 node.removeAttribute(origName); 216 node.removeAttribute(origName);
192 var propertyName = Polymer.CaseMap.dashToCamelCase(name); 217 var propertyName = Polymer.CaseMap.dashToCamelCase(name);
193 if (kind === 'property') { 218 if (kind === 'property') {
194 name = propertyName; 219 name = propertyName;
195 } 220 }
196 return { 221 return {
197 kind: kind, 222 kind: kind,
198 name: name, 223 name: name,
199 propertyName: propertyName, 224 propertyName: propertyName,
200 parts: parts, 225 parts: parts,
201 literal: literal, 226 literal: literal,
202 isCompound: parts.length !== 1 227 isCompound: parts.length !== 1
203 }; 228 };
204 } 229 }
205 }, 230 },
206 findAnnotatedNode: function (root, annote) { 231 findAnnotatedNode: function (root, annote) {
207 var parent = annote.parent && Polymer.Annotations.findAnnotatedNode(root, annote .parent); 232 var parent = annote.parent && Polymer.Annotations.findAnnotatedNode(root, annote .parent);
208 if (parent) { 233 if (parent) {
209 for (var n = parent.firstChild, i = 0; n; n = n.nextSibling) { 234 for (var n = parent.firstChild, i = 0; n; n = n.nextSibling) {
210 if (annote.index === i++) { 235 if (annote.index === i++) {
211 return n; 236 return n;
212 } 237 }
213 } 238 }
214 } else { 239 } else {
215 return root; 240 return root;
216 } 241 }
217 } 242 }
218 };(function () { 243 };
244 }());(function () {
219 function resolveCss(cssText, ownerDocument) { 245 function resolveCss(cssText, ownerDocument) {
220 return cssText.replace(CSS_URL_RX, function (m, pre, url, post) { 246 return cssText.replace(CSS_URL_RX, function (m, pre, url, post) {
221 return pre + '\'' + resolve(url.replace(/["']/g, ''), ownerDocument) + '\'' + po st; 247 return pre + '\'' + resolve(url.replace(/["']/g, ''), ownerDocument) + '\'' + po st;
222 }); 248 });
223 } 249 }
224 function resolveAttrs(element, ownerDocument) { 250 function resolveAttrs(element, ownerDocument) {
225 for (var name in URL_ATTRS) { 251 for (var name in URL_ATTRS) {
226 var a$ = URL_ATTRS[name]; 252 var a$ = URL_ATTRS[name];
227 for (var i = 0, l = a$.length, a, at, v; i < l && (a = a$[i]); i++) { 253 for (var i = 0, l = a$.length, a, at, v; i < l && (a = a$[i]); i++) {
228 if (name === '*' || element.localName === name) { 254 if (name === '*' || element.localName === name) {
(...skipping 19 matching lines...) Expand all
248 function resolveUrl(url, baseUri) { 274 function resolveUrl(url, baseUri) {
249 if (!tempDoc) { 275 if (!tempDoc) {
250 tempDoc = document.implementation.createHTMLDocument('temp'); 276 tempDoc = document.implementation.createHTMLDocument('temp');
251 tempDocBase = tempDoc.createElement('base'); 277 tempDocBase = tempDoc.createElement('base');
252 tempDoc.head.appendChild(tempDocBase); 278 tempDoc.head.appendChild(tempDocBase);
253 } 279 }
254 tempDocBase.href = baseUri; 280 tempDocBase.href = baseUri;
255 return resolve(url, tempDoc); 281 return resolve(url, tempDoc);
256 } 282 }
257 function getUrlResolver(ownerDocument) { 283 function getUrlResolver(ownerDocument) {
258 return ownerDocument.__urlResolver || (ownerDocument.__urlResolver = ownerDocume nt.createElement('a')); 284 return ownerDocument.body.__urlResolver || (ownerDocument.body.__urlResolver = o wnerDocument.createElement('a'));
259 } 285 }
260 var CSS_URL_RX = /(url\()([^)]*)(\))/g; 286 var CSS_URL_RX = /(url\()([^)]*)(\))/g;
261 var URL_ATTRS = { 287 var URL_ATTRS = {
262 '*': [ 288 '*': [
263 'href', 289 'href',
264 'src', 290 'src',
265 'style', 291 'style',
266 'url' 292 'url'
267 ], 293 ],
268 form: ['action'] 294 form: ['action']
269 }; 295 };
270 var ABS_URL = /(^\/)|(^#)|(^[\w-\d]*:)/; 296 var ABS_URL = /(^\/)|(^#)|(^[\w-\d]*:)/;
271 var BINDING_RX = /\{\{|\[\[/; 297 var BINDING_RX = /\{\{|\[\[/;
272 Polymer.ResolveUrl = { 298 Polymer.ResolveUrl = {
273 resolveCss: resolveCss, 299 resolveCss: resolveCss,
274 resolveAttrs: resolveAttrs, 300 resolveAttrs: resolveAttrs,
275 resolveUrl: resolveUrl 301 resolveUrl: resolveUrl
276 }; 302 };
277 }());Polymer.Base._addFeature({ 303 }());Polymer.Path = {
304 root: function (path) {
305 var dotIndex = path.indexOf('.');
306 if (dotIndex === -1) {
307 return path;
308 }
309 return path.slice(0, dotIndex);
310 },
311 isDeep: function (path) {
312 return path.indexOf('.') !== -1;
313 },
314 isAncestor: function (base, path) {
315 return base.indexOf(path + '.') === 0;
316 },
317 isDescendant: function (base, path) {
318 return path.indexOf(base + '.') === 0;
319 },
320 translate: function (base, newBase, path) {
321 return newBase + path.slice(base.length);
322 },
323 matches: function (base, wildcard, path) {
324 return base === path || this.isAncestor(base, path) || Boolean(wildcard) && this .isDescendant(base, path);
325 }
326 };Polymer.Base._addFeature({
278 _prepAnnotations: function () { 327 _prepAnnotations: function () {
279 if (!this._template) { 328 if (!this._template) {
280 this._notes = []; 329 this._notes = [];
281 } else { 330 } else {
282 var self = this; 331 var self = this;
283 Polymer.Annotations.prepElement = function (element) { 332 Polymer.Annotations.prepElement = function (element) {
284 self._prepElement(element); 333 self._prepElement(element);
285 }; 334 };
286 if (this._template._content && this._template._content._notes) { 335 if (this._template._content && this._template._content._notes) {
287 this._notes = this._template._content._notes; 336 this._notes = this._template._content._notes;
288 } else { 337 } else {
289 this._notes = Polymer.Annotations.parseAnnotations(this._template); 338 this._notes = Polymer.Annotations.parseAnnotations(this._template);
290 this._processAnnotations(this._notes); 339 this._processAnnotations(this._notes);
291 } 340 }
292 Polymer.Annotations.prepElement = null; 341 Polymer.Annotations.prepElement = null;
293 } 342 }
294 }, 343 },
295 _processAnnotations: function (notes) { 344 _processAnnotations: function (notes) {
296 for (var i = 0; i < notes.length; i++) { 345 for (var i = 0; i < notes.length; i++) {
297 var note = notes[i]; 346 var note = notes[i];
298 for (var j = 0; j < note.bindings.length; j++) { 347 for (var j = 0; j < note.bindings.length; j++) {
299 var b = note.bindings[j]; 348 var b = note.bindings[j];
300 for (var k = 0; k < b.parts.length; k++) { 349 for (var k = 0; k < b.parts.length; k++) {
301 var p = b.parts[k]; 350 var p = b.parts[k];
302 if (!p.literal) { 351 if (!p.literal) {
303 var signature = this._parseMethod(p.value); 352 var signature = this._parseMethod(p.value);
304 if (signature) { 353 if (signature) {
305 p.signature = signature; 354 p.signature = signature;
306 } else { 355 } else {
307 p.model = this._modelForPath(p.value); 356 p.model = Polymer.Path.root(p.value);
308 } 357 }
309 } 358 }
310 } 359 }
311 } 360 }
312 if (note.templateContent) { 361 if (note.templateContent) {
313 this._processAnnotations(note.templateContent._notes); 362 this._processAnnotations(note.templateContent._notes);
314 var pp = note.templateContent._parentProps = this._discoverTemplateParentProps(n ote.templateContent._notes); 363 var pp = note.templateContent._parentProps = this._discoverTemplateParentProps(n ote.templateContent._notes);
315 var bindings = []; 364 var bindings = [];
316 for (var prop in pp) { 365 for (var prop in pp) {
317 var name = '_parent_' + prop; 366 var name = '_parent_' + prop;
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 return eventName + ':' + methodName; 517 return eventName + ':' + methodName;
469 }, 518 },
470 _recordEventHandler: function (host, eventName, target, methodName, handler) { 519 _recordEventHandler: function (host, eventName, target, methodName, handler) {
471 var hbl = host.__boundListeners; 520 var hbl = host.__boundListeners;
472 if (!hbl) { 521 if (!hbl) {
473 hbl = host.__boundListeners = new WeakMap(); 522 hbl = host.__boundListeners = new WeakMap();
474 } 523 }
475 var bl = hbl.get(target); 524 var bl = hbl.get(target);
476 if (!bl) { 525 if (!bl) {
477 bl = {}; 526 bl = {};
527 if (!Polymer.Settings.isIE || target != window) {
478 hbl.set(target, bl); 528 hbl.set(target, bl);
479 } 529 }
530 }
480 var key = this._boundListenerKey(eventName, methodName); 531 var key = this._boundListenerKey(eventName, methodName);
481 bl[key] = handler; 532 bl[key] = handler;
482 }, 533 },
483 _recallEventHandler: function (host, eventName, target, methodName) { 534 _recallEventHandler: function (host, eventName, target, methodName) {
484 var hbl = host.__boundListeners; 535 var hbl = host.__boundListeners;
485 if (!hbl) { 536 if (!hbl) {
486 return; 537 return;
487 } 538 }
488 var bl = hbl.get(target); 539 var bl = hbl.get(target);
489 if (!bl) { 540 if (!bl) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 4, 592 4,
542 2 593 2
543 ]; 594 ];
544 var MOUSE_HAS_BUTTONS = function () { 595 var MOUSE_HAS_BUTTONS = function () {
545 try { 596 try {
546 return new MouseEvent('test', { buttons: 1 }).buttons === 1; 597 return new MouseEvent('test', { buttons: 1 }).buttons === 1;
547 } catch (e) { 598 } catch (e) {
548 return false; 599 return false;
549 } 600 }
550 }(); 601 }();
602 var SUPPORTS_PASSIVE = false;
603 (function () {
604 try {
605 var opts = Object.defineProperty({}, 'passive', {
606 get: function () {
607 SUPPORTS_PASSIVE = true;
608 }
609 });
610 window.addEventListener('test', null, opts);
611 window.removeEventListener('test', null, opts);
612 } catch (e) {
613 }
614 }());
551 var IS_TOUCH_ONLY = navigator.userAgent.match(/iP(?:[oa]d|hone)|Android/); 615 var IS_TOUCH_ONLY = navigator.userAgent.match(/iP(?:[oa]d|hone)|Android/);
552 var mouseCanceller = function (mouseEvent) { 616 var mouseCanceller = function (mouseEvent) {
553 var sc = mouseEvent.sourceCapabilities; 617 var sc = mouseEvent.sourceCapabilities;
554 if (sc && !sc.firesTouchEvents) { 618 if (sc && !sc.firesTouchEvents) {
555 return; 619 return;
556 } 620 }
557 mouseEvent[HANDLED_OBJ] = { skip: true }; 621 mouseEvent[HANDLED_OBJ] = { skip: true };
558 if (mouseEvent.type === 'click') { 622 if (mouseEvent.type === 'click') {
559 var path = Polymer.dom(mouseEvent).path; 623 var path = Polymer.dom(mouseEvent).path;
560 for (var i = 0; i < path.length; i++) { 624 for (var i = 0; i < path.length; i++) {
561 if (path[i] === POINTERSTATE.mouse.target) { 625 if (path[i] === POINTERSTATE.mouse.target) {
562 return; 626 return;
563 } 627 }
564 } 628 }
565 mouseEvent.preventDefault(); 629 mouseEvent.preventDefault();
566 mouseEvent.stopPropagation(); 630 mouseEvent.stopPropagation();
567 } 631 }
568 }; 632 };
569 function setupTeardownMouseCanceller(setup) { 633 function setupTeardownMouseCanceller(setup) {
570 for (var i = 0, en; i < MOUSE_EVENTS.length; i++) { 634 var events = IS_TOUCH_ONLY ? ['click'] : MOUSE_EVENTS;
571 en = MOUSE_EVENTS[i]; 635 for (var i = 0, en; i < events.length; i++) {
636 en = events[i];
572 if (setup) { 637 if (setup) {
573 document.addEventListener(en, mouseCanceller, true); 638 document.addEventListener(en, mouseCanceller, true);
574 } else { 639 } else {
575 document.removeEventListener(en, mouseCanceller, true); 640 document.removeEventListener(en, mouseCanceller, true);
576 } 641 }
577 } 642 }
578 } 643 }
579 function ignoreMouse() { 644 function ignoreMouse(ev) {
580 if (IS_TOUCH_ONLY) {
581 return;
582 }
583 if (!POINTERSTATE.mouse.mouseIgnoreJob) { 645 if (!POINTERSTATE.mouse.mouseIgnoreJob) {
584 setupTeardownMouseCanceller(true); 646 setupTeardownMouseCanceller(true);
585 } 647 }
586 var unset = function () { 648 var unset = function () {
587 setupTeardownMouseCanceller(); 649 setupTeardownMouseCanceller();
588 POINTERSTATE.mouse.target = null; 650 POINTERSTATE.mouse.target = null;
589 POINTERSTATE.mouse.mouseIgnoreJob = null; 651 POINTERSTATE.mouse.mouseIgnoreJob = null;
590 }; 652 };
653 POINTERSTATE.mouse.target = Polymer.dom(ev).rootTarget;
591 POINTERSTATE.mouse.mouseIgnoreJob = Polymer.Debounce(POINTERSTATE.mouse.mouseIgn oreJob, unset, MOUSE_TIMEOUT); 654 POINTERSTATE.mouse.mouseIgnoreJob = Polymer.Debounce(POINTERSTATE.mouse.mouseIgn oreJob, unset, MOUSE_TIMEOUT);
592 } 655 }
593 function hasLeftMouseButton(ev) { 656 function hasLeftMouseButton(ev) {
594 var type = ev.type; 657 var type = ev.type;
595 if (MOUSE_EVENTS.indexOf(type) === -1) { 658 if (MOUSE_EVENTS.indexOf(type) === -1) {
596 return false; 659 return false;
597 } 660 }
598 if (type === 'mousemove') { 661 if (type === 'mousemove') {
599 var buttons = ev.buttons === undefined ? 1 : ev.buttons; 662 var buttons = ev.buttons === undefined ? 1 : ev.buttons;
600 if (ev instanceof window.MouseEvent && !MOUSE_HAS_BUTTONS) { 663 if (ev instanceof window.MouseEvent && !MOUSE_HAS_BUTTONS) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 stateObj.upfn = upfn; 710 stateObj.upfn = upfn;
648 document.addEventListener('mousemove', movefn); 711 document.addEventListener('mousemove', movefn);
649 document.addEventListener('mouseup', upfn); 712 document.addEventListener('mouseup', upfn);
650 } 713 }
651 function untrackDocument(stateObj) { 714 function untrackDocument(stateObj) {
652 document.removeEventListener('mousemove', stateObj.movefn); 715 document.removeEventListener('mousemove', stateObj.movefn);
653 document.removeEventListener('mouseup', stateObj.upfn); 716 document.removeEventListener('mouseup', stateObj.upfn);
654 stateObj.movefn = null; 717 stateObj.movefn = null;
655 stateObj.upfn = null; 718 stateObj.upfn = null;
656 } 719 }
720 document.addEventListener('touchend', ignoreMouse, SUPPORTS_PASSIVE ? { passive: true } : false);
657 var Gestures = { 721 var Gestures = {
658 gestures: {}, 722 gestures: {},
659 recognizers: [], 723 recognizers: [],
660 deepTargetFind: function (x, y) { 724 deepTargetFind: function (x, y) {
661 var node = document.elementFromPoint(x, y); 725 var node = document.elementFromPoint(x, y);
662 var next = node; 726 var next = node;
663 while (next && next.shadowRoot) { 727 while (next && next.shadowRoot) {
664 next = next.shadowRoot.elementFromPoint(x, y); 728 next = next.shadowRoot.elementFromPoint(x, y);
665 if (next) { 729 if (next) {
666 node = next; 730 node = next;
(...skipping 29 matching lines...) Expand all
696 } 760 }
697 } 761 }
698 if (POINTERSTATE.touch.id !== t.identifier) { 762 if (POINTERSTATE.touch.id !== t.identifier) {
699 return; 763 return;
700 } 764 }
701 if (!HAS_NATIVE_TA) { 765 if (!HAS_NATIVE_TA) {
702 if (type === 'touchstart' || type === 'touchmove') { 766 if (type === 'touchstart' || type === 'touchmove') {
703 Gestures.handleTouchAction(ev); 767 Gestures.handleTouchAction(ev);
704 } 768 }
705 } 769 }
706 if (type === 'touchend') {
707 POINTERSTATE.mouse.target = Polymer.dom(ev).rootTarget;
708 ignoreMouse();
709 }
710 } 770 }
711 } 771 }
712 handled = ev[HANDLED_OBJ]; 772 handled = ev[HANDLED_OBJ];
713 if (handled.skip) { 773 if (handled.skip) {
714 return; 774 return;
715 } 775 }
716 var recognizers = Gestures.recognizers; 776 var recognizers = Gestures.recognizers;
717 for (var i = 0, r; i < recognizers.length; i++) { 777 for (var i = 0, r; i < recognizers.length; i++) {
718 r = recognizers[i]; 778 r = recognizers[i];
719 if (gs[r.name] && !handled[r.name]) { 779 if (gs[r.name] && !handled[r.name]) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 node = wrap(node); 825 node = wrap(node);
766 var recognizer = this.gestures[evType]; 826 var recognizer = this.gestures[evType];
767 var deps = recognizer.deps; 827 var deps = recognizer.deps;
768 var name = recognizer.name; 828 var name = recognizer.name;
769 var gobj = node[GESTURE_KEY]; 829 var gobj = node[GESTURE_KEY];
770 if (!gobj) { 830 if (!gobj) {
771 node[GESTURE_KEY] = gobj = {}; 831 node[GESTURE_KEY] = gobj = {};
772 } 832 }
773 for (var i = 0, dep, gd; i < deps.length; i++) { 833 for (var i = 0, dep, gd; i < deps.length; i++) {
774 dep = deps[i]; 834 dep = deps[i];
775 if (IS_TOUCH_ONLY && MOUSE_EVENTS.indexOf(dep) > -1) { 835 if (IS_TOUCH_ONLY && MOUSE_EVENTS.indexOf(dep) > -1 && dep !== 'click') {
776 continue; 836 continue;
777 } 837 }
778 gd = gobj[dep]; 838 gd = gobj[dep];
779 if (!gd) { 839 if (!gd) {
780 gobj[dep] = gd = { _count: 0 }; 840 gobj[dep] = gd = { _count: 0 };
781 } 841 }
782 if (gd._count === 0) { 842 if (gd._count === 0) {
783 node.addEventListener(dep, this.handleNative); 843 node.addEventListener(dep, this.handleNative);
784 } 844 }
785 gd[name] = (gd[name] || 0) + 1; 845 gd[name] = (gd[name] || 0) + 1;
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
1315 this.transform('translate3d(' + x + ',' + y + ',' + z + ')', node); 1375 this.transform('translate3d(' + x + ',' + y + ',' + z + ')', node);
1316 }, 1376 },
1317 importHref: function (href, onload, onerror, optAsync) { 1377 importHref: function (href, onload, onerror, optAsync) {
1318 var link = document.createElement('link'); 1378 var link = document.createElement('link');
1319 link.rel = 'import'; 1379 link.rel = 'import';
1320 link.href = href; 1380 link.href = href;
1321 var list = Polymer.Base.importHref.imported = Polymer.Base.importHref.imported | | {}; 1381 var list = Polymer.Base.importHref.imported = Polymer.Base.importHref.imported | | {};
1322 var cached = list[link.href]; 1382 var cached = list[link.href];
1323 var imprt = cached || link; 1383 var imprt = cached || link;
1324 var self = this; 1384 var self = this;
1325 if (onload) {
1326 var loadListener = function (e) { 1385 var loadListener = function (e) {
1327 e.target.__firedLoad = true; 1386 e.target.__firedLoad = true;
1328 e.target.removeEventListener('load', loadListener); 1387 e.target.removeEventListener('load', loadListener);
1388 e.target.removeEventListener('error', errorListener);
1329 return onload.call(self, e); 1389 return onload.call(self, e);
1330 }; 1390 };
1391 var errorListener = function (e) {
1392 e.target.__firedError = true;
1393 e.target.removeEventListener('load', loadListener);
1394 e.target.removeEventListener('error', errorListener);
1395 return onerror.call(self, e);
1396 };
1397 if (onload) {
1331 imprt.addEventListener('load', loadListener); 1398 imprt.addEventListener('load', loadListener);
1332 } 1399 }
1333 if (onerror) { 1400 if (onerror) {
1334 var errorListener = function (e) {
1335 e.target.__firedError = true;
1336 e.target.removeEventListener('error', errorListener);
1337 return onerror.call(self, e);
1338 };
1339 imprt.addEventListener('error', errorListener); 1401 imprt.addEventListener('error', errorListener);
1340 } 1402 }
1341 if (cached) { 1403 if (cached) {
1342 if (cached.__firedLoad) { 1404 if (cached.__firedLoad) {
1343 cached.dispatchEvent(new Event('load')); 1405 cached.dispatchEvent(new Event('load'));
1344 } 1406 }
1345 if (cached.__firedError) { 1407 if (cached.__firedError) {
1346 cached.dispatchEvent(new Event('error')); 1408 cached.dispatchEvent(new Event('error'));
1347 } 1409 }
1348 } else { 1410 } else {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1389 prepareModel: function (model) { 1451 prepareModel: function (model) {
1390 Polymer.Base.mixin(model, this._modelApi); 1452 Polymer.Base.mixin(model, this._modelApi);
1391 }, 1453 },
1392 _modelApi: { 1454 _modelApi: {
1393 _notifyChange: function (source, event, value) { 1455 _notifyChange: function (source, event, value) {
1394 value = value === undefined ? this[source] : value; 1456 value = value === undefined ? this[source] : value;
1395 event = event || Polymer.CaseMap.camelToDashCase(source) + '-changed'; 1457 event = event || Polymer.CaseMap.camelToDashCase(source) + '-changed';
1396 this.fire(event, { value: value }, { 1458 this.fire(event, { value: value }, {
1397 bubbles: false, 1459 bubbles: false,
1398 cancelable: false, 1460 cancelable: false,
1399 _useCache: true 1461 _useCache: Polymer.Settings.eventDataCache || !Polymer.Settings.isIE
1400 }); 1462 });
1401 }, 1463 },
1402 _propertySetter: function (property, value, effects, fromAbove) { 1464 _propertySetter: function (property, value, effects, fromAbove) {
1403 var old = this.__data__[property]; 1465 var old = this.__data__[property];
1404 if (old !== value && (old === old || value === value)) { 1466 if (old !== value && (old === old || value === value)) {
1405 this.__data__[property] = value; 1467 this.__data__[property] = value;
1406 if (typeof value == 'object') { 1468 if (typeof value == 'object') {
1407 this._clearPath(property); 1469 this._clearPath(property);
1408 } 1470 }
1409 if (this._propertyChanged) { 1471 if (this._propertyChanged) {
(...skipping 14 matching lines...) Expand all
1424 node[property] = value; 1486 node[property] = value;
1425 } 1487 }
1426 }, 1488 },
1427 _effectEffects: function (property, value, effects, old, fromAbove) { 1489 _effectEffects: function (property, value, effects, old, fromAbove) {
1428 for (var i = 0, l = effects.length, fx; i < l && (fx = effects[i]); i++) { 1490 for (var i = 0, l = effects.length, fx; i < l && (fx = effects[i]); i++) {
1429 fx.fn.call(this, property, this[property], fx.effect, old, fromAbove); 1491 fx.fn.call(this, property, this[property], fx.effect, old, fromAbove);
1430 } 1492 }
1431 }, 1493 },
1432 _clearPath: function (path) { 1494 _clearPath: function (path) {
1433 for (var prop in this.__data__) { 1495 for (var prop in this.__data__) {
1434 if (prop.indexOf(path + '.') === 0) { 1496 if (Polymer.Path.isDescendant(path, prop)) {
1435 this.__data__[prop] = undefined; 1497 this.__data__[prop] = undefined;
1436 } 1498 }
1437 } 1499 }
1438 } 1500 }
1439 }, 1501 },
1440 ensurePropertyEffects: function (model, property) { 1502 ensurePropertyEffects: function (model, property) {
1441 if (!model._propertyEffects) { 1503 if (!model._propertyEffects) {
1442 model._propertyEffects = {}; 1504 model._propertyEffects = {};
1443 } 1505 }
1444 var fx = model._propertyEffects[property]; 1506 var fx = model._propertyEffects[property];
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 } 1563 }
1502 Object.defineProperty(model, property, defun); 1564 Object.defineProperty(model, property, defun);
1503 }, 1565 },
1504 upper: function (name) { 1566 upper: function (name) {
1505 return name[0].toUpperCase() + name.substring(1); 1567 return name[0].toUpperCase() + name.substring(1);
1506 }, 1568 },
1507 _addAnnotatedListener: function (model, index, property, path, event, negated) { 1569 _addAnnotatedListener: function (model, index, property, path, event, negated) {
1508 if (!model._bindListeners) { 1570 if (!model._bindListeners) {
1509 model._bindListeners = []; 1571 model._bindListeners = [];
1510 } 1572 }
1511 var fn = this._notedListenerFactory(property, path, this._isStructured(path), ne gated); 1573 var fn = this._notedListenerFactory(property, path, Polymer.Path.isDeep(path), n egated);
1512 var eventName = event || Polymer.CaseMap.camelToDashCase(property) + '-changed'; 1574 var eventName = event || Polymer.CaseMap.camelToDashCase(property) + '-changed';
1513 model._bindListeners.push({ 1575 model._bindListeners.push({
1514 index: index, 1576 index: index,
1515 property: property, 1577 property: property,
1516 path: path, 1578 path: path,
1517 changedFn: fn, 1579 changedFn: fn,
1518 event: eventName 1580 event: eventName
1519 }); 1581 });
1520 }, 1582 },
1521 _isStructured: function (path) {
1522 return path.indexOf('.') > 0;
1523 },
1524 _isEventBogus: function (e, target) { 1583 _isEventBogus: function (e, target) {
1525 return e.path && e.path[0] !== target; 1584 return e.path && e.path[0] !== target;
1526 }, 1585 },
1527 _notedListenerFactory: function (property, path, isStructured, negated) { 1586 _notedListenerFactory: function (property, path, isStructured, negated) {
1528 return function (target, value, targetPath) { 1587 return function (target, value, targetPath) {
1529 if (targetPath) { 1588 if (targetPath) {
1530 this._notifyPath(this._fixPath(path, property, targetPath), value); 1589 var newPath = Polymer.Path.translate(property, path, targetPath);
1590 this._notifyPath(newPath, value);
1531 } else { 1591 } else {
1532 value = target[property]; 1592 value = target[property];
1533 if (negated) { 1593 if (negated) {
1534 value = !value; 1594 value = !value;
1535 } 1595 }
1536 if (!isStructured) { 1596 if (!isStructured) {
1537 this[path] = value; 1597 this[path] = value;
1538 } else { 1598 } else {
1539 if (this.__data__[path] != value) { 1599 if (this.__data__[path] != value) {
1540 this.set(path, value); 1600 this.set(path, value);
(...skipping 10 matching lines...) Expand all
1551 for (var i = 0, l = b$.length, info; i < l && (info = b$[i]); i++) { 1611 for (var i = 0, l = b$.length, info; i < l && (info = b$[i]); i++) {
1552 var node = inst._nodes[info.index]; 1612 var node = inst._nodes[info.index];
1553 this._addNotifyListener(node, inst, info.event, info.changedFn); 1613 this._addNotifyListener(node, inst, info.event, info.changedFn);
1554 } 1614 }
1555 }, 1615 },
1556 _addNotifyListener: function (element, context, event, changedFn) { 1616 _addNotifyListener: function (element, context, event, changedFn) {
1557 element.addEventListener(event, function (e) { 1617 element.addEventListener(event, function (e) {
1558 return context._notifyListener(changedFn, e); 1618 return context._notifyListener(changedFn, e);
1559 }); 1619 });
1560 } 1620 }
1561 };Polymer.Base.extend(Polymer.Bind, { 1621 };Polymer.Base.mixin(Polymer.Bind, {
1562 _shouldAddListener: function (effect) { 1622 _shouldAddListener: function (effect) {
1563 return effect.name && effect.kind != 'attribute' && effect.kind != 'text' && !ef fect.isCompound && effect.parts[0].mode === '{'; 1623 return effect.name && effect.kind != 'attribute' && effect.kind != 'text' && !ef fect.isCompound && effect.parts[0].mode === '{';
1564 }, 1624 },
1565 _annotationEffect: function (source, value, effect) { 1625 _annotationEffect: function (source, value, effect) {
1566 if (source != effect.value) { 1626 if (source != effect.value) {
1567 value = this._get(effect.value); 1627 value = this._get(effect.value);
1568 this.__data__[effect.value] = value; 1628 this.__data__[effect.value] = value;
1569 } 1629 }
1570 this._applyEffectValue(effect, value); 1630 this._applyEffectValue(effect, value);
1571 }, 1631 },
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1642 } else { 1702 } else {
1643 v = model[name]; 1703 v = model[name];
1644 if (v === undefined && arg.structured) { 1704 if (v === undefined && arg.structured) {
1645 v = Polymer.Base._get(name, model); 1705 v = Polymer.Base._get(name, model);
1646 } 1706 }
1647 } 1707 }
1648 if (bailoutEarly && v === undefined) { 1708 if (bailoutEarly && v === undefined) {
1649 return; 1709 return;
1650 } 1710 }
1651 if (arg.wildcard) { 1711 if (arg.wildcard) {
1652 var matches = path.indexOf(name + '.') === 0; 1712 var matches = Polymer.Path.isAncestor(path, name);
1653 values[i] = { 1713 values[i] = {
1654 path: matches ? path : name, 1714 path: matches ? path : name,
1655 value: matches ? value : v, 1715 value: matches ? value : v,
1656 base: v 1716 base: v
1657 }; 1717 };
1658 } else { 1718 } else {
1659 values[i] = v; 1719 values[i] = v;
1660 } 1720 }
1661 } 1721 }
1662 return values; 1722 return values;
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1869 case '"': 1929 case '"':
1870 a.value = arg.slice(1, -1); 1930 a.value = arg.slice(1, -1);
1871 a.literal = true; 1931 a.literal = true;
1872 break; 1932 break;
1873 case '#': 1933 case '#':
1874 a.value = Number(arg); 1934 a.value = Number(arg);
1875 a.literal = true; 1935 a.literal = true;
1876 break; 1936 break;
1877 } 1937 }
1878 if (!a.literal) { 1938 if (!a.literal) {
1879 a.model = this._modelForPath(arg); 1939 a.model = Polymer.Path.root(arg);
1880 a.structured = arg.indexOf('.') > 0; 1940 a.structured = Polymer.Path.isDeep(arg);
1881 if (a.structured) { 1941 if (a.structured) {
1882 a.wildcard = arg.slice(-2) == '.*'; 1942 a.wildcard = arg.slice(-2) == '.*';
1883 if (a.wildcard) { 1943 if (a.wildcard) {
1884 a.name = arg.slice(0, -2); 1944 a.name = arg.slice(0, -2);
1885 } 1945 }
1886 } 1946 }
1887 } 1947 }
1888 return a; 1948 return a;
1889 }, 1949 },
1890 _marshalInstanceEffects: function () { 1950 _marshalInstanceEffects: function () {
1891 Polymer.Bind.prepareInstance(this); 1951 Polymer.Bind.prepareInstance(this);
1892 if (this._bindListeners) { 1952 if (this._bindListeners) {
1893 Polymer.Bind.setupBindListeners(this); 1953 Polymer.Bind.setupBindListeners(this);
1894 } 1954 }
1895 }, 1955 },
1896 _applyEffectValue: function (info, value) { 1956 _applyEffectValue: function (info, value) {
1897 var node = this._nodes[info.index]; 1957 var node = this._nodes[info.index];
1898 var property = info.name; 1958 var property = info.name;
1899 value = this._computeFinalAnnotationValue(node, property, value, info); 1959 value = this._computeFinalAnnotationValue(node, property, value, info);
1900 if (info.kind == 'attribute') { 1960 if (info.kind == 'attribute') {
1901 this.serializeValueToAttribute(value, property, node); 1961 this.serializeValueToAttribute(value, property, node);
1902 } else { 1962 } else {
1903 var pinfo = node._propertyInfo && node._propertyInfo[property]; 1963 var pinfo = node._propertyInfo && node._propertyInfo[property];
1904 if (pinfo && pinfo.readOnly) { 1964 if (pinfo && pinfo.readOnly) {
1905 return; 1965 return;
1906 } 1966 }
1907 this.__setProperty(property, value, false, node); 1967 this.__setProperty(property, value, Polymer.Settings.suppressBindingNotification s, node);
1908 } 1968 }
1909 }, 1969 },
1910 _computeFinalAnnotationValue: function (node, property, value, info) { 1970 _computeFinalAnnotationValue: function (node, property, value, info) {
1911 if (info.negate) { 1971 if (info.negate) {
1912 value = !value; 1972 value = !value;
1913 } 1973 }
1914 if (info.isCompound) { 1974 if (info.isCompound) {
1915 var storage = node.__compoundStorage__[property]; 1975 var storage = node.__compoundStorage__[property];
1916 storage[info.compoundIndex] = value; 1976 storage[info.compoundIndex] = value;
1917 value = storage.join(''); 1977 value = storage.join('');
1918 } 1978 }
1919 if (info.kind !== 'attribute') { 1979 if (info.kind !== 'attribute') {
1920 if (property === 'className') { 1980 if (property === 'className') {
1921 value = this._scopeElementClass(node, value); 1981 value = this._scopeElementClass(node, value);
1922 } 1982 }
1923 if (property === 'textContent' || node.localName == 'input' && property == 'valu e') { 1983 if (property === 'textContent' || node.localName == 'input' && property == 'valu e') {
1924 value = value == undefined ? '' : value; 1984 value = value == undefined ? '' : value;
1925 } 1985 }
1926 } 1986 }
1927 return value; 1987 return value;
1928 }, 1988 },
1929 _executeStaticEffects: function () { 1989 _executeStaticEffects: function () {
1930 if (this._propertyEffects && this._propertyEffects.__static__) { 1990 if (this._propertyEffects && this._propertyEffects.__static__) {
1931 this._effectEffects('__static__', null, this._propertyEffects.__static__); 1991 this._effectEffects('__static__', null, this._propertyEffects.__static__);
1932 } 1992 }
1933 } 1993 }
1934 });(function () { 1994 });(function () {
1935 var usePolyfillProto = Polymer.Settings.usePolyfillProto; 1995 var usePolyfillProto = Polymer.Settings.usePolyfillProto;
1996 var avoidInstanceProperties = Boolean(Object.getOwnPropertyDescriptor(document.d ocumentElement, 'properties'));
1936 Polymer.Base._addFeature({ 1997 Polymer.Base._addFeature({
1937 _setupConfigure: function (initialConfig) { 1998 _setupConfigure: function (initialConfig) {
1938 this._config = {}; 1999 this._config = {};
1939 this._handlers = []; 2000 this._handlers = [];
1940 this._aboveConfig = null; 2001 this._aboveConfig = null;
1941 if (initialConfig) { 2002 if (initialConfig) {
1942 for (var i in initialConfig) { 2003 for (var i in initialConfig) {
1943 if (initialConfig[i] !== undefined) { 2004 if (initialConfig[i] !== undefined) {
1944 this._config[i] = initialConfig[i]; 2005 this._config[i] = initialConfig[i];
1945 } 2006 }
(...skipping 17 matching lines...) Expand all
1963 this._configure(); 2024 this._configure();
1964 }, 2025 },
1965 _configure: function () { 2026 _configure: function () {
1966 this._configureAnnotationReferences(); 2027 this._configureAnnotationReferences();
1967 this._configureInstanceProperties(); 2028 this._configureInstanceProperties();
1968 this._aboveConfig = this.mixin({}, this._config); 2029 this._aboveConfig = this.mixin({}, this._config);
1969 var config = {}; 2030 var config = {};
1970 for (var i = 0; i < this.behaviors.length; i++) { 2031 for (var i = 0; i < this.behaviors.length; i++) {
1971 this._configureProperties(this.behaviors[i].properties, config); 2032 this._configureProperties(this.behaviors[i].properties, config);
1972 } 2033 }
1973 this._configureProperties(this.properties, config); 2034 this._configureProperties(avoidInstanceProperties ? this.__proto__.properties : this.properties, config);
1974 this.mixin(config, this._aboveConfig); 2035 this.mixin(config, this._aboveConfig);
1975 this._config = config; 2036 this._config = config;
1976 if (this._clients && this._clients.length) { 2037 if (this._clients && this._clients.length) {
1977 this._distributeConfig(this._config); 2038 this._distributeConfig(this._config);
1978 } 2039 }
1979 }, 2040 },
1980 _configureInstanceProperties: function () { 2041 _configureInstanceProperties: function () {
1981 for (var i in this._propertyEffects) { 2042 for (var i in this._propertyEffects) {
1982 if (!usePolyfillProto && this.hasOwnProperty(i)) { 2043 if (!usePolyfillProto && this.hasOwnProperty(i)) {
1983 this._configValue(i, this[i]); 2044 this._configValue(i, this[i]);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
2060 _flushHandlers: function () { 2121 _flushHandlers: function () {
2061 var h$ = this._handlers; 2122 var h$ = this._handlers;
2062 for (var i = 0, l = h$.length, h; i < l && (h = h$[i]); i++) { 2123 for (var i = 0, l = h$.length, h; i < l && (h = h$[i]); i++) {
2063 h[0].call(this, h[1], h[2], h[3]); 2124 h[0].call(this, h[1], h[2], h[3]);
2064 } 2125 }
2065 this._handlers = []; 2126 this._handlers = [];
2066 } 2127 }
2067 }); 2128 });
2068 }());(function () { 2129 }());(function () {
2069 'use strict'; 2130 'use strict';
2131 var Path = Polymer.Path;
2070 Polymer.Base._addFeature({ 2132 Polymer.Base._addFeature({
2071 notifyPath: function (path, value, fromAbove) { 2133 notifyPath: function (path, value, fromAbove) {
2072 var info = {}; 2134 var info = {};
2073 var v = this._get(path, this, info); 2135 var v = this._get(path, this, info);
2074 if (arguments.length === 1) { 2136 if (arguments.length === 1) {
2075 value = v; 2137 value = v;
2076 } 2138 }
2077 if (info.path) { 2139 if (info.path) {
2078 this._notifyPath(info.path, value, fromAbove); 2140 this._notifyPath(info.path, value, fromAbove);
2079 } 2141 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
2167 } 2229 }
2168 } 2230 }
2169 array = Array.isArray(prop) ? prop : null; 2231 array = Array.isArray(prop) ? prop : null;
2170 } 2232 }
2171 if (info) { 2233 if (info) {
2172 info.path = parts.join('.'); 2234 info.path = parts.join('.');
2173 } 2235 }
2174 return prop; 2236 return prop;
2175 }, 2237 },
2176 _pathEffector: function (path, value) { 2238 _pathEffector: function (path, value) {
2177 var model = this._modelForPath(path); 2239 var model = Path.root(path);
2178 var fx$ = this._propertyEffects && this._propertyEffects[model]; 2240 var fx$ = this._propertyEffects && this._propertyEffects[model];
2179 if (fx$) { 2241 if (fx$) {
2180 for (var i = 0, fx; i < fx$.length && (fx = fx$[i]); i++) { 2242 for (var i = 0, fx; i < fx$.length && (fx = fx$[i]); i++) {
2181 var fxFn = fx.pathFn; 2243 var fxFn = fx.pathFn;
2182 if (fxFn) { 2244 if (fxFn) {
2183 fxFn.call(this, path, value, fx.effect); 2245 fxFn.call(this, path, value, fx.effect);
2184 } 2246 }
2185 } 2247 }
2186 } 2248 }
2187 if (this._boundPaths) { 2249 if (this._boundPaths) {
2188 this._notifyBoundPaths(path, value); 2250 this._notifyBoundPaths(path, value);
2189 } 2251 }
2190 }, 2252 },
2191 _annotationPathEffect: function (path, value, effect) { 2253 _annotationPathEffect: function (path, value, effect) {
2192 if (effect.value === path || effect.value.indexOf(path + '.') === 0) { 2254 if (Path.matches(effect.value, false, path)) {
2193 Polymer.Bind._annotationEffect.call(this, path, value, effect); 2255 Polymer.Bind._annotationEffect.call(this, path, value, effect);
2194 } else if (path.indexOf(effect.value + '.') === 0 && !effect.negate) { 2256 } else if (!effect.negate && Path.isDescendant(effect.value, path)) {
2195 var node = this._nodes[effect.index]; 2257 var node = this._nodes[effect.index];
2196 if (node && node._notifyPath) { 2258 if (node && node._notifyPath) {
2197 var p = this._fixPath(effect.name, effect.value, path); 2259 var newPath = Path.translate(effect.value, effect.name, path);
2198 node._notifyPath(p, value, true); 2260 node._notifyPath(newPath, value, true);
2199 } 2261 }
2200 } 2262 }
2201 }, 2263 },
2202 _complexObserverPathEffect: function (path, value, effect) { 2264 _complexObserverPathEffect: function (path, value, effect) {
2203 if (this._pathMatchesEffect(path, effect)) { 2265 if (Path.matches(effect.trigger.name, effect.trigger.wildcard, path)) {
2204 Polymer.Bind._complexObserverEffect.call(this, path, value, effect); 2266 Polymer.Bind._complexObserverEffect.call(this, path, value, effect);
2205 } 2267 }
2206 }, 2268 },
2207 _computePathEffect: function (path, value, effect) { 2269 _computePathEffect: function (path, value, effect) {
2208 if (this._pathMatchesEffect(path, effect)) { 2270 if (Path.matches(effect.trigger.name, effect.trigger.wildcard, path)) {
2209 Polymer.Bind._computeEffect.call(this, path, value, effect); 2271 Polymer.Bind._computeEffect.call(this, path, value, effect);
2210 } 2272 }
2211 }, 2273 },
2212 _annotatedComputationPathEffect: function (path, value, effect) { 2274 _annotatedComputationPathEffect: function (path, value, effect) {
2213 if (this._pathMatchesEffect(path, effect)) { 2275 if (Path.matches(effect.trigger.name, effect.trigger.wildcard, path)) {
2214 Polymer.Bind._annotatedComputationEffect.call(this, path, value, effect); 2276 Polymer.Bind._annotatedComputationEffect.call(this, path, value, effect);
2215 } 2277 }
2216 }, 2278 },
2217 _pathMatchesEffect: function (path, effect) {
2218 var effectArg = effect.trigger.name;
2219 return effectArg == path || effectArg.indexOf(path + '.') === 0 || effect.trigge r.wildcard && path.indexOf(effectArg + '.') === 0;
2220 },
2221 linkPaths: function (to, from) { 2279 linkPaths: function (to, from) {
2222 this._boundPaths = this._boundPaths || {}; 2280 this._boundPaths = this._boundPaths || {};
2223 if (from) { 2281 if (from) {
2224 this._boundPaths[to] = from; 2282 this._boundPaths[to] = from;
2225 } else { 2283 } else {
2226 this.unlinkPaths(to); 2284 this.unlinkPaths(to);
2227 } 2285 }
2228 }, 2286 },
2229 unlinkPaths: function (path) { 2287 unlinkPaths: function (path) {
2230 if (this._boundPaths) { 2288 if (this._boundPaths) {
2231 delete this._boundPaths[path]; 2289 delete this._boundPaths[path];
2232 } 2290 }
2233 }, 2291 },
2234 _notifyBoundPaths: function (path, value) { 2292 _notifyBoundPaths: function (path, value) {
2235 for (var a in this._boundPaths) { 2293 for (var a in this._boundPaths) {
2236 var b = this._boundPaths[a]; 2294 var b = this._boundPaths[a];
2237 if (path.indexOf(a + '.') == 0) { 2295 if (Path.isDescendant(a, path)) {
2238 this._notifyPath(this._fixPath(b, a, path), value); 2296 this._notifyPath(Path.translate(a, b, path), value);
2239 } else if (path.indexOf(b + '.') == 0) { 2297 } else if (Path.isDescendant(b, path)) {
2240 this._notifyPath(this._fixPath(a, b, path), value); 2298 this._notifyPath(Path.translate(b, a, path), value);
2241 } 2299 }
2242 } 2300 }
2243 }, 2301 },
2244 _fixPath: function (property, root, path) {
2245 return property + path.slice(root.length);
2246 },
2247 _notifyPathUp: function (path, value) { 2302 _notifyPathUp: function (path, value) {
2248 var rootName = this._modelForPath(path); 2303 var rootName = Path.root(path);
2249 var dashCaseName = Polymer.CaseMap.camelToDashCase(rootName); 2304 var dashCaseName = Polymer.CaseMap.camelToDashCase(rootName);
2250 var eventName = dashCaseName + this._EVENT_CHANGED; 2305 var eventName = dashCaseName + this._EVENT_CHANGED;
2251 this.fire(eventName, { 2306 this.fire(eventName, {
2252 path: path, 2307 path: path,
2253 value: value 2308 value: value
2254 }, { 2309 }, {
2255 bubbles: false, 2310 bubbles: false,
2256 _useCache: true 2311 _useCache: Polymer.Settings.eventDataCache || !Polymer.Settings.isIE
2257 }); 2312 });
2258 }, 2313 },
2259 _modelForPath: function (path) {
2260 var dot = path.indexOf('.');
2261 return dot < 0 ? path : path.slice(0, dot);
2262 },
2263 _EVENT_CHANGED: '-changed', 2314 _EVENT_CHANGED: '-changed',
2264 notifySplices: function (path, splices) { 2315 notifySplices: function (path, splices) {
2265 var info = {}; 2316 var info = {};
2266 var array = this._get(path, this, info); 2317 var array = this._get(path, this, info);
2267 this._notifySplices(array, info.path, splices); 2318 this._notifySplices(array, info.path, splices);
2268 }, 2319 },
2269 _notifySplices: function (array, path, splices) { 2320 _notifySplices: function (array, path, splices) {
2270 var change = { 2321 var change = {
2271 keySplices: Polymer.Collection.applySplices(array, splices), 2322 keySplices: Polymer.Collection.applySplices(array, splices),
2272 indexSplices: splices 2323 indexSplices: splices
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
2358 notifyPath: Polymer.Base.notifyPath, 2409 notifyPath: Polymer.Base.notifyPath,
2359 _get: Polymer.Base._get, 2410 _get: Polymer.Base._get,
2360 _EVENT_CHANGED: Polymer.Base._EVENT_CHANGED, 2411 _EVENT_CHANGED: Polymer.Base._EVENT_CHANGED,
2361 _notifyPath: Polymer.Base._notifyPath, 2412 _notifyPath: Polymer.Base._notifyPath,
2362 _notifyPathUp: Polymer.Base._notifyPathUp, 2413 _notifyPathUp: Polymer.Base._notifyPathUp,
2363 _pathEffector: Polymer.Base._pathEffector, 2414 _pathEffector: Polymer.Base._pathEffector,
2364 _annotationPathEffect: Polymer.Base._annotationPathEffect, 2415 _annotationPathEffect: Polymer.Base._annotationPathEffect,
2365 _complexObserverPathEffect: Polymer.Base._complexObserverPathEffect, 2416 _complexObserverPathEffect: Polymer.Base._complexObserverPathEffect,
2366 _annotatedComputationPathEffect: Polymer.Base._annotatedComputationPathEffect, 2417 _annotatedComputationPathEffect: Polymer.Base._annotatedComputationPathEffect,
2367 _computePathEffect: Polymer.Base._computePathEffect, 2418 _computePathEffect: Polymer.Base._computePathEffect,
2368 _modelForPath: Polymer.Base._modelForPath,
2369 _pathMatchesEffect: Polymer.Base._pathMatchesEffect,
2370 _notifyBoundPaths: Polymer.Base._notifyBoundPaths, 2419 _notifyBoundPaths: Polymer.Base._notifyBoundPaths,
2371 _getPathParts: Polymer.Base._getPathParts 2420 _getPathParts: Polymer.Base._getPathParts
2372 }); 2421 });
2373 } 2422 }
2374 }); 2423 });
2375 }());Polymer.Base._addFeature({ 2424 }());Polymer.Base._addFeature({
2376 resolveUrl: function (url) { 2425 resolveUrl: function (url) {
2377 var module = Polymer.DomModule.import(this.is); 2426 var module = Polymer.DomModule.import(this.is);
2378 var root = ''; 2427 var root = '';
2379 if (module) { 2428 if (module) {
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
2653 } 2702 }
2654 return m && m._cssText || ''; 2703 return m && m._cssText || '';
2655 }, 2704 },
2656 cssFromElement: function (element) { 2705 cssFromElement: function (element) {
2657 var cssText = ''; 2706 var cssText = '';
2658 var content = element.content || element; 2707 var content = element.content || element;
2659 var e$ = Polymer.TreeApi.arrayCopy(content.querySelectorAll(this.MODULE_STYLES_S ELECTOR)); 2708 var e$ = Polymer.TreeApi.arrayCopy(content.querySelectorAll(this.MODULE_STYLES_S ELECTOR));
2660 for (var i = 0, e; i < e$.length; i++) { 2709 for (var i = 0, e; i < e$.length; i++) {
2661 e = e$[i]; 2710 e = e$[i];
2662 if (e.localName === 'template') { 2711 if (e.localName === 'template') {
2712 if (!e.hasAttribute('preserve-content')) {
2663 cssText += this.cssFromElement(e); 2713 cssText += this.cssFromElement(e);
2714 }
2664 } else { 2715 } else {
2665 if (e.localName === 'style') { 2716 if (e.localName === 'style') {
2666 var include = e.getAttribute(this.INCLUDE_ATTR); 2717 var include = e.getAttribute(this.INCLUDE_ATTR);
2667 if (include) { 2718 if (include) {
2668 cssText += this.cssFromModules(include, true); 2719 cssText += this.cssFromModules(include, true);
2669 } 2720 }
2670 e = e.__appliedElement || e; 2721 e = e.__appliedElement || e;
2671 e.parentNode.removeChild(e); 2722 e.parentNode.removeChild(e);
2672 cssText += this.resolveCss(e.textContent, element.ownerDocument); 2723 cssText += this.resolveCss(e.textContent, element.ownerDocument);
2673 } else if (e.import && e.import.body) { 2724 } else if (e.import && e.import.body) {
2674 cssText += this.resolveCss(e.import.body.textContent, e.import); 2725 cssText += this.resolveCss(e.import.body.textContent, e.import);
2675 } 2726 }
2676 } 2727 }
2677 } 2728 }
2678 return cssText; 2729 return cssText;
2679 }, 2730 },
2731 styleIncludesToTemplate: function (targetTemplate) {
2732 var styles = targetTemplate.content.querySelectorAll('style[include]');
2733 for (var i = 0, s; i < styles.length; i++) {
2734 s = styles[i];
2735 s.parentNode.insertBefore(this._includesToFragment(s.getAttribute('include')), s );
2736 }
2737 },
2738 _includesToFragment: function (styleIncludes) {
2739 var includeArray = styleIncludes.trim().split(' ');
2740 var frag = document.createDocumentFragment();
2741 for (var i = 0; i < includeArray.length; i++) {
2742 var t = Polymer.DomModule.import(includeArray[i], 'template');
2743 if (t) {
2744 this._addStylesToFragment(frag, t.content);
2745 }
2746 }
2747 return frag;
2748 },
2749 _addStylesToFragment: function (frag, source) {
2750 var s$ = source.querySelectorAll('style');
2751 for (var i = 0, s; i < s$.length; i++) {
2752 s = s$[i];
2753 var include = s.getAttribute('include');
2754 if (include) {
2755 frag.appendChild(this._includesToFragment(include));
2756 }
2757 if (s.textContent) {
2758 frag.appendChild(s.cloneNode(true));
2759 }
2760 }
2761 },
2680 isTargetedBuild: function (buildType) { 2762 isTargetedBuild: function (buildType) {
2681 return settings.useNativeShadow ? buildType === 'shadow' : buildType === 'shady' ; 2763 return settings.useNativeShadow ? buildType === 'shadow' : buildType === 'shady' ;
2682 }, 2764 },
2683 cssBuildTypeForModule: function (module) { 2765 cssBuildTypeForModule: function (module) {
2684 var dm = Polymer.DomModule.import(module); 2766 var dm = Polymer.DomModule.import(module);
2685 if (dm) { 2767 if (dm) {
2686 return this.getCssBuildType(dm); 2768 return this.getCssBuildType(dm);
2687 } 2769 }
2688 }, 2770 },
2689 getCssBuildType: function (element) { 2771 getCssBuildType: function (element) {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
2780 element.setAttribute(CLASS, (c ? c + ' ' : '') + SCOPE_NAME + ' ' + scope); 2862 element.setAttribute(CLASS, (c ? c + ' ' : '') + SCOPE_NAME + ' ' + scope);
2781 } 2863 }
2782 } 2864 }
2783 } 2865 }
2784 } 2866 }
2785 }, 2867 },
2786 elementStyles: function (element, callback) { 2868 elementStyles: function (element, callback) {
2787 var styles = element._styles; 2869 var styles = element._styles;
2788 var cssText = ''; 2870 var cssText = '';
2789 var cssBuildType = element.__cssBuild; 2871 var cssBuildType = element.__cssBuild;
2872 var passthrough = settings.useNativeShadow || cssBuildType === 'shady';
2873 var cb;
2874 if (passthrough) {
2875 var self = this;
2876 cb = function (rule) {
2877 rule.selector = self._slottedToContent(rule.selector);
2878 rule.selector = rule.selector.replace(ROOT, ':host > *');
2879 if (callback) {
2880 callback(rule);
2881 }
2882 };
2883 }
2790 for (var i = 0, l = styles.length, s; i < l && (s = styles[i]); i++) { 2884 for (var i = 0, l = styles.length, s; i < l && (s = styles[i]); i++) {
2791 var rules = styleUtil.rulesForStyle(s); 2885 var rules = styleUtil.rulesForStyle(s);
2792 cssText += settings.useNativeShadow || cssBuildType === 'shady' ? styleUtil.toCs sText(rules, callback) : this.css(rules, element.is, element.extends, callback, element._scopeCssViaAttr) + '\n\n'; 2886 cssText += passthrough ? styleUtil.toCssText(rules, cb) : this.css(rules, elemen t.is, element.extends, callback, element._scopeCssViaAttr) + '\n\n';
2793 } 2887 }
2794 return cssText.trim(); 2888 return cssText.trim();
2795 }, 2889 },
2796 css: function (rules, scope, ext, callback, useAttr) { 2890 css: function (rules, scope, ext, callback, useAttr) {
2797 var hostScope = this._calcHostScope(scope, ext); 2891 var hostScope = this._calcHostScope(scope, ext);
2798 scope = this._calcElementScope(scope, useAttr); 2892 scope = this._calcElementScope(scope, useAttr);
2799 var self = this; 2893 var self = this;
2800 return styleUtil.toCssText(rules, function (rule) { 2894 return styleUtil.toCssText(rules, function (rule) {
2801 if (!rule.isScoped) { 2895 if (!rule.isScoped) {
2802 self.rule(rule, scope, hostScope); 2896 self.rule(rule, scope, hostScope);
(...skipping 27 matching lines...) Expand all
2830 p$[i] = transformer.call(this, p, scope, hostScope); 2924 p$[i] = transformer.call(this, p, scope, hostScope);
2831 } 2925 }
2832 } 2926 }
2833 return p$.join(COMPLEX_SELECTOR_SEP); 2927 return p$.join(COMPLEX_SELECTOR_SEP);
2834 }, 2928 },
2835 _transformComplexSelector: function (selector, scope, hostScope) { 2929 _transformComplexSelector: function (selector, scope, hostScope) {
2836 var stop = false; 2930 var stop = false;
2837 var hostContext = false; 2931 var hostContext = false;
2838 var self = this; 2932 var self = this;
2839 selector = selector.trim(); 2933 selector = selector.trim();
2934 selector = this._slottedToContent(selector);
2935 selector = selector.replace(ROOT, ':host > *');
2840 selector = selector.replace(CONTENT_START, HOST + ' $1'); 2936 selector = selector.replace(CONTENT_START, HOST + ' $1');
2841 selector = selector.replace(SIMPLE_SELECTOR_SEP, function (m, c, s) { 2937 selector = selector.replace(SIMPLE_SELECTOR_SEP, function (m, c, s) {
2842 if (!stop) { 2938 if (!stop) {
2843 var info = self._transformCompoundSelector(s, c, scope, hostScope); 2939 var info = self._transformCompoundSelector(s, c, scope, hostScope);
2844 stop = stop || info.stop; 2940 stop = stop || info.stop;
2845 hostContext = hostContext || info.hostContext; 2941 hostContext = hostContext || info.hostContext;
2846 c = info.combinator; 2942 c = info.combinator;
2847 s = info.value; 2943 s = info.value;
2848 } else { 2944 } else {
2849 s = s.replace(SCOPE_JUMP, ' '); 2945 s = s.replace(SCOPE_JUMP, ' ');
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
2908 } 3004 }
2909 }, 3005 },
2910 documentRule: function (rule) { 3006 documentRule: function (rule) {
2911 rule.selector = rule.parsedSelector; 3007 rule.selector = rule.parsedSelector;
2912 this.normalizeRootSelector(rule); 3008 this.normalizeRootSelector(rule);
2913 if (!settings.useNativeShadow) { 3009 if (!settings.useNativeShadow) {
2914 this._transformRule(rule, this._transformDocumentSelector); 3010 this._transformRule(rule, this._transformDocumentSelector);
2915 } 3011 }
2916 }, 3012 },
2917 normalizeRootSelector: function (rule) { 3013 normalizeRootSelector: function (rule) {
2918 if (rule.selector === ROOT) { 3014 rule.selector = rule.selector.replace(ROOT, 'html');
2919 rule.selector = 'html';
2920 }
2921 }, 3015 },
2922 _transformDocumentSelector: function (selector) { 3016 _transformDocumentSelector: function (selector) {
2923 return selector.match(SCOPE_JUMP) ? this._transformComplexSelector(selector, SCO PE_DOC_SELECTOR) : this._transformSimpleSelector(selector.trim(), SCOPE_DOC_SELE CTOR); 3017 return selector.match(SCOPE_JUMP) ? this._transformComplexSelector(selector, SCO PE_DOC_SELECTOR) : this._transformSimpleSelector(selector.trim(), SCOPE_DOC_SELE CTOR);
2924 }, 3018 },
3019 _slottedToContent: function (cssText) {
3020 return cssText.replace(SLOTTED_PAREN, CONTENT + '> $1');
3021 },
2925 SCOPE_NAME: 'style-scope' 3022 SCOPE_NAME: 'style-scope'
2926 }; 3023 };
2927 var SCOPE_NAME = api.SCOPE_NAME; 3024 var SCOPE_NAME = api.SCOPE_NAME;
2928 var SCOPE_DOC_SELECTOR = ':not([' + SCOPE_NAME + '])' + ':not(.' + SCOPE_NAME + ')'; 3025 var SCOPE_DOC_SELECTOR = ':not([' + SCOPE_NAME + '])' + ':not(.' + SCOPE_NAME + ')';
2929 var COMPLEX_SELECTOR_SEP = ','; 3026 var COMPLEX_SELECTOR_SEP = ',';
2930 var SIMPLE_SELECTOR_SEP = /(^|[\s>+~]+)((?:\[.+?\]|[^\s>+~=\[])+)/g; 3027 var SIMPLE_SELECTOR_SEP = /(^|[\s>+~]+)((?:\[.+?\]|[^\s>+~=\[])+)/g;
2931 var SIMPLE_SELECTOR_PREFIX = /[[.:#*]/; 3028 var SIMPLE_SELECTOR_PREFIX = /[[.:#*]/;
2932 var HOST = ':host'; 3029 var HOST = ':host';
2933 var ROOT = ':root'; 3030 var ROOT = ':root';
2934 var HOST_PAREN = /(:host)(?:\(((?:\([^)(]*\)|[^)(]*)+?)\))/; 3031 var HOST_PAREN = /(:host)(?:\(((?:\([^)(]*\)|[^)(]*)+?)\))/;
2935 var HOST_CONTEXT = ':host-context'; 3032 var HOST_CONTEXT = ':host-context';
2936 var HOST_CONTEXT_PAREN = /(.*)(?::host-context)(?:\(((?:\([^)(]*\)|[^)(]*)+?)\)) (.*)/; 3033 var HOST_CONTEXT_PAREN = /(.*)(?::host-context)(?:\(((?:\([^)(]*\)|[^)(]*)+?)\)) (.*)/;
2937 var CONTENT = '::content'; 3034 var CONTENT = '::content';
2938 var SCOPE_JUMP = /::content|::shadow|\/deep\//; 3035 var SCOPE_JUMP = /::content|::shadow|\/deep\//;
2939 var CSS_CLASS_PREFIX = '.'; 3036 var CSS_CLASS_PREFIX = '.';
2940 var CSS_ATTR_PREFIX = '[' + SCOPE_NAME + '~='; 3037 var CSS_ATTR_PREFIX = '[' + SCOPE_NAME + '~=';
2941 var CSS_ATTR_SUFFIX = ']'; 3038 var CSS_ATTR_SUFFIX = ']';
2942 var PSEUDO_PREFIX = ':'; 3039 var PSEUDO_PREFIX = ':';
2943 var CLASS = 'class'; 3040 var CLASS = 'class';
2944 var CONTENT_START = new RegExp('^(' + CONTENT + ')'); 3041 var CONTENT_START = new RegExp('^(' + CONTENT + ')');
2945 var SELECTOR_NO_MATCH = 'should_not_match'; 3042 var SELECTOR_NO_MATCH = 'should_not_match';
3043 var SLOTTED_PAREN = /(?:::slotted)(?:\(((?:\([^)(]*\)|[^)(]*)+?)\))/g;
2946 return api; 3044 return api;
2947 }();Polymer.StyleExtends = function () { 3045 }();Polymer.StyleExtends = function () {
2948 var styleUtil = Polymer.StyleUtil; 3046 var styleUtil = Polymer.StyleUtil;
2949 return { 3047 return {
2950 hasExtends: function (cssText) { 3048 hasExtends: function (cssText) {
2951 return Boolean(cssText.match(this.rx.EXTEND)); 3049 return Boolean(cssText.match(this.rx.EXTEND));
2952 }, 3050 },
2953 transform: function (style) { 3051 transform: function (style) {
2954 var rules = styleUtil.rulesForStyle(style); 3052 var rules = styleUtil.rulesForStyle(style);
2955 var self = this; 3053 var self = this;
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
3113 } 3211 }
3114 if (mixinEntry) { 3212 if (mixinEntry) {
3115 mixinEntry.properties = combinedProps; 3213 mixinEntry.properties = combinedProps;
3116 } 3214 }
3117 if (valueProperty) { 3215 if (valueProperty) {
3118 prefix = matchText + ';' + prefix; 3216 prefix = matchText + ';' + prefix;
3119 } 3217 }
3120 return prefix + out.join('; ') + ';'; 3218 return prefix + out.join('; ') + ';';
3121 } 3219 }
3122 function fixVars(matchText, varA, varB) { 3220 function fixVars(matchText, varA, varB) {
3123 return 'var(' + varA + ',' + 'var(' + varB + '));'; 3221 return 'var(' + varA + ',' + 'var(' + varB + '))';
3124 } 3222 }
3125 function atApplyToCssProperties(mixinName, fallbacks) { 3223 function atApplyToCssProperties(mixinName, fallbacks) {
3126 mixinName = mixinName.replace(APPLY_NAME_CLEAN, ''); 3224 mixinName = mixinName.replace(APPLY_NAME_CLEAN, '');
3127 var vars = []; 3225 var vars = [];
3128 var mixinEntry = mapGet(mixinName); 3226 var mixinEntry = mapGet(mixinName);
3129 if (!mixinEntry) { 3227 if (!mixinEntry) {
3130 mapSet(mixinName, {}); 3228 mapSet(mixinName, {});
3131 mixinEntry = mapGet(mixinName); 3229 mixinEntry = mapGet(mixinName);
3132 } 3230 }
3133 if (mixinEntry) { 3231 if (mixinEntry) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
3174 MIXIN_MATCH.lastIndex = idx + replacement.length; 3272 MIXIN_MATCH.lastIndex = idx + replacement.length;
3175 } 3273 }
3176 return text; 3274 return text;
3177 } 3275 }
3178 var ApplyShim = { 3276 var ApplyShim = {
3179 _measureElement: null, 3277 _measureElement: null,
3180 _map: mixinMap, 3278 _map: mixinMap,
3181 _separator: MIXIN_VAR_SEP, 3279 _separator: MIXIN_VAR_SEP,
3182 transform: function (styles, elementProto) { 3280 transform: function (styles, elementProto) {
3183 this.__currentElementProto = elementProto; 3281 this.__currentElementProto = elementProto;
3184 styleUtil.forRulesInStyles(styles, this._boundTransformRule); 3282 styleUtil.forRulesInStyles(styles, this._boundFindDefinitions);
3283 styleUtil.forRulesInStyles(styles, this._boundFindApplications);
3284 if (elementProto) {
3185 elementProto.__applyShimInvalid = false; 3285 elementProto.__applyShimInvalid = false;
3286 }
3186 this.__currentElementProto = null; 3287 this.__currentElementProto = null;
3187 }, 3288 },
3188 transformRule: function (rule) { 3289 _findDefinitions: function (rule) {
3189 rule.cssText = this.transformCssText(rule.parsedCssText); 3290 var cssText = rule.parsedCssText;
3291 cssText = cssText.replace(BAD_VAR, fixVars);
3292 cssText = cssText.replace(VAR_ASSIGN, produceCssProperties);
3293 rule.cssText = cssText;
3190 if (rule.selector === ':root') { 3294 if (rule.selector === ':root') {
3191 rule.selector = ':host > *'; 3295 rule.selector = ':host > *';
3192 } 3296 }
3193 }, 3297 },
3194 transformCssText: function (cssText) { 3298 _findApplications: function (rule) {
3195 cssText = cssText.replace(BAD_VAR, fixVars); 3299 rule.cssText = consumeCssProperties(rule.cssText);
3196 cssText = cssText.replace(VAR_ASSIGN, produceCssProperties); 3300 },
3197 return consumeCssProperties(cssText); 3301 transformRule: function (rule) {
3302 this._findDefinitions(rule);
3303 this._findApplications(rule);
3198 }, 3304 },
3199 _getInitialValueForProperty: function (property) { 3305 _getInitialValueForProperty: function (property) {
3200 if (!this._measureElement) { 3306 if (!this._measureElement) {
3201 this._measureElement = document.createElement('meta'); 3307 this._measureElement = document.createElement('meta');
3202 this._measureElement.style.all = 'initial'; 3308 this._measureElement.style.all = 'initial';
3203 document.head.appendChild(this._measureElement); 3309 document.head.appendChild(this._measureElement);
3204 } 3310 }
3205 return window.getComputedStyle(this._measureElement).getPropertyValue(property); 3311 return window.getComputedStyle(this._measureElement).getPropertyValue(property);
3206 } 3312 }
3207 }; 3313 };
3208 ApplyShim._boundTransformRule = ApplyShim.transformRule.bind(ApplyShim); 3314 ApplyShim._boundTransformRule = ApplyShim.transformRule.bind(ApplyShim);
3315 ApplyShim._boundFindDefinitions = ApplyShim._findDefinitions.bind(ApplyShim);
3316 ApplyShim._boundFindApplications = ApplyShim._findApplications.bind(ApplyShim);
3209 return ApplyShim; 3317 return ApplyShim;
3210 }();(function () { 3318 }();(function () {
3211 var prepElement = Polymer.Base._prepElement; 3319 var prepElement = Polymer.Base._prepElement;
3212 var nativeShadow = Polymer.Settings.useNativeShadow; 3320 var nativeShadow = Polymer.Settings.useNativeShadow;
3213 var styleUtil = Polymer.StyleUtil; 3321 var styleUtil = Polymer.StyleUtil;
3214 var styleTransformer = Polymer.StyleTransformer; 3322 var styleTransformer = Polymer.StyleTransformer;
3215 var styleExtends = Polymer.StyleExtends; 3323 var styleExtends = Polymer.StyleExtends;
3216 var applyShim = Polymer.ApplyShim; 3324 var applyShim = Polymer.ApplyShim;
3217 var settings = Polymer.Settings; 3325 var settings = Polymer.Settings;
3218 Polymer.Base._addFeature({ 3326 Polymer.Base._addFeature({
3219 _prepElement: function (element) { 3327 _prepElement: function (element) {
3220 if (this._encapsulateStyle && this.__cssBuild !== 'shady') { 3328 if (this._encapsulateStyle && this.__cssBuild !== 'shady') {
3221 styleTransformer.element(element, this.is, this._scopeCssViaAttr); 3329 styleTransformer.element(element, this.is, this._scopeCssViaAttr);
3222 } 3330 }
3223 prepElement.call(this, element); 3331 prepElement.call(this, element);
3224 }, 3332 },
3225 _prepStyles: function () { 3333 _prepStyles: function () {
3226 if (this._encapsulateStyle === undefined) { 3334 if (this._encapsulateStyle === undefined) {
3227 this._encapsulateStyle = !nativeShadow; 3335 this._encapsulateStyle = !nativeShadow;
3228 } 3336 }
3229 if (!nativeShadow) { 3337 if (!nativeShadow) {
3230 this._scopeStyle = styleUtil.applyStylePlaceHolder(this.is); 3338 this._scopeStyle = styleUtil.applyStylePlaceHolder(this.is);
3231 } 3339 }
3232 this.__cssBuild = styleUtil.cssBuildTypeForModule(this.is); 3340 this.__cssBuild = styleUtil.cssBuildTypeForModule(this.is);
3233 }, 3341 },
3234 _prepShimStyles: function () { 3342 _prepShimStyles: function () {
3235 if (this._template) { 3343 if (this._template) {
3236 var hasTargetedCssBuild = styleUtil.isTargetedBuild(this.__cssBuild); 3344 var hasTargetedCssBuild = styleUtil.isTargetedBuild(this.__cssBuild);
3237 if (settings.useNativeCSSProperties && this.__cssBuild === 'shadow' && hasTarget edCssBuild) { 3345 if (settings.useNativeCSSProperties && this.__cssBuild === 'shadow' && hasTarget edCssBuild) {
3346 if (settings.preserveStyleIncludes) {
3347 styleUtil.styleIncludesToTemplate(this._template);
3348 }
3238 return; 3349 return;
3239 } 3350 }
3240 this._styles = this._styles || this._collectStyles(); 3351 this._styles = this._styles || this._collectStyles();
3241 if (settings.useNativeCSSProperties && !this.__cssBuild) { 3352 if (settings.useNativeCSSProperties && !this.__cssBuild) {
3242 applyShim.transform(this._styles, this); 3353 applyShim.transform(this._styles, this);
3243 } 3354 }
3244 var cssText = settings.useNativeCSSProperties && hasTargetedCssBuild ? this._sty les.length && this._styles[0].textContent.trim() : styleTransformer.elementStyle s(this); 3355 var cssText = settings.useNativeCSSProperties && hasTargetedCssBuild ? this._sty les.length && this._styles[0].textContent.trim() : styleTransformer.elementStyle s(this);
3245 this._prepStyleProperties(); 3356 this._prepStyleProperties();
3246 if (!this._needsStyleProperties() && cssText) { 3357 if (!this._needsStyleProperties() && cssText) {
3247 styleUtil.applyCss(cssText, this.is, nativeShadow ? this._template.content : nul l, this._scopeStyle); 3358 styleUtil.applyCss(cssText, this.is, nativeShadow ? this._template.content : nul l, this._scopeStyle);
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
3509 self.collectProperties(rule, props); 3620 self.collectProperties(rule, props);
3510 addToBitMask(rule.index, o); 3621 addToBitMask(rule.index, o);
3511 } 3622 }
3512 } 3623 }
3513 }); 3624 });
3514 return { 3625 return {
3515 properties: props, 3626 properties: props,
3516 key: o 3627 key: o
3517 }; 3628 };
3518 }, 3629 },
3630 _rootSelector: /:root|:host\s*>\s*\*/,
3631 _checkRoot: function (hostScope, selector) {
3632 return Boolean(selector.match(this._rootSelector)) || hostScope === 'html' && se lector.indexOf('html') > -1;
3633 },
3519 whenHostOrRootRule: function (scope, rule, style, callback) { 3634 whenHostOrRootRule: function (scope, rule, style, callback) {
3520 if (!rule.propertyInfo) { 3635 if (!rule.propertyInfo) {
3521 self.decorateRule(rule); 3636 self.decorateRule(rule);
3522 } 3637 }
3523 if (!rule.propertyInfo.properties) { 3638 if (!rule.propertyInfo.properties) {
3524 return; 3639 return;
3525 } 3640 }
3526 var hostScope = scope.is ? styleTransformer._calcHostScope(scope.is, scope.exten ds) : 'html'; 3641 var hostScope = scope.is ? styleTransformer._calcHostScope(scope.is, scope.exten ds) : 'html';
3527 var parsedSelector = rule.parsedSelector; 3642 var parsedSelector = rule.parsedSelector;
3528 var isRoot = parsedSelector === ':root'; 3643 var isRoot = this._checkRoot(hostScope, parsedSelector);
3529 var isHost = parsedSelector.indexOf(':host') === 0; 3644 var isHost = !isRoot && parsedSelector.indexOf(':host') === 0;
3530 var cssBuild = scope.__cssBuild || style.__cssBuild; 3645 var cssBuild = scope.__cssBuild || style.__cssBuild;
3531 if (cssBuild === 'shady') { 3646 if (cssBuild === 'shady') {
3532 isRoot = parsedSelector === hostScope + ' > *.' + hostScope || parsedSelector.in dexOf('html') !== -1; 3647 isRoot = parsedSelector === hostScope + ' > *.' + hostScope || parsedSelector.in dexOf('html') > -1;
3533 isHost = !isRoot && parsedSelector.indexOf(hostScope) === 0; 3648 isHost = !isRoot && parsedSelector.indexOf(hostScope) === 0;
3534 } 3649 }
3535 if (cssBuild === 'shadow') {
3536 isRoot = parsedSelector === ':host > *' || parsedSelector === 'html';
3537 isHost = isHost && !isRoot;
3538 }
3539 if (!isRoot && !isHost) { 3650 if (!isRoot && !isHost) {
3540 return; 3651 return;
3541 } 3652 }
3542 var selectorToMatch = hostScope; 3653 var selectorToMatch = hostScope;
3543 if (isHost) { 3654 if (isHost) {
3544 if (settings.useNativeShadow && !rule.transformedSelector) { 3655 if (settings.useNativeShadow && !rule.transformedSelector) {
3545 rule.transformedSelector = styleTransformer._transformRuleCss(rule, styleTransfo rmer._transformComplexSelector, scope.is, hostScope); 3656 rule.transformedSelector = styleTransformer._transformRuleCss(rule, styleTransfo rmer._transformComplexSelector, scope.is, hostScope);
3546 } 3657 }
3547 selectorToMatch = rule.transformedSelector || rule.parsedSelector; 3658 selectorToMatch = rule.transformedSelector || rule.parsedSelector;
3548 } 3659 }
3660 if (isRoot && hostScope === 'html') {
3661 selectorToMatch = rule.transformedSelector || rule.parsedSelector;
3662 }
3549 callback({ 3663 callback({
3550 selector: selectorToMatch, 3664 selector: selectorToMatch,
3551 isHost: isHost, 3665 isHost: isHost,
3552 isRoot: isRoot 3666 isRoot: isRoot
3553 }); 3667 });
3554 }, 3668 },
3555 hostAndRootPropertiesForScope: function (scope) { 3669 hostAndRootPropertiesForScope: function (scope) {
3556 var hostProps = {}, rootProps = {}, self = this; 3670 var hostProps = {}, rootProps = {}, self = this;
3557 styleUtil.forActiveRulesInStyles(scope._styles, function (rule, style) { 3671 styleUtil.forActiveRulesInStyles(scope._styles, function (rule, style) {
3558 self.whenHostOrRootRule(scope, rule, style, function (info) { 3672 self.whenHostOrRootRule(scope, rule, style, function (info) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
3643 style = element._customStyle; 3757 style = element._customStyle;
3644 } else if (cssText) { 3758 } else if (cssText) {
3645 style = styleUtil.applyCss(cssText, selector, element.root, element._scopeStyle) ; 3759 style = styleUtil.applyCss(cssText, selector, element.root, element._scopeStyle) ;
3646 } 3760 }
3647 } else { 3761 } else {
3648 if (!style) { 3762 if (!style) {
3649 if (cssText) { 3763 if (cssText) {
3650 style = styleUtil.applyCss(cssText, selector, null, element._scopeStyle); 3764 style = styleUtil.applyCss(cssText, selector, null, element._scopeStyle);
3651 } 3765 }
3652 } else if (!style.parentNode) { 3766 } else if (!style.parentNode) {
3767 if (IS_IE && cssText.indexOf('@media') > -1) {
3768 style.textContent = cssText;
3769 }
3653 styleUtil.applyStyle(style, null, element._scopeStyle); 3770 styleUtil.applyStyle(style, null, element._scopeStyle);
3654 } 3771 }
3655 } 3772 }
3656 if (style) { 3773 if (style) {
3657 style._useCount = style._useCount || 0; 3774 style._useCount = style._useCount || 0;
3658 if (element._customStyle != style) { 3775 if (element._customStyle != style) {
3659 style._useCount++; 3776 style._useCount++;
3660 } 3777 }
3661 element._customStyle = style; 3778 element._customStyle = style;
3662 } 3779 }
3663 if (IS_IE) {
3664 style.textContent = style.textContent;
3665 }
3666 return style; 3780 return style;
3667 }, 3781 },
3668 mixinCustomStyle: function (props, customStyle) { 3782 mixinCustomStyle: function (props, customStyle) {
3669 var v; 3783 var v;
3670 for (var i in customStyle) { 3784 for (var i in customStyle) {
3671 v = customStyle[i]; 3785 v = customStyle[i];
3672 if (v || v === 0) { 3786 if (v || v === 0) {
3673 props[i] = v; 3787 props[i] = v;
3674 } 3788 }
3675 } 3789 }
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
3802 var nativeShadow = Polymer.Settings.useNativeShadow; 3916 var nativeShadow = Polymer.Settings.useNativeShadow;
3803 var nativeVariables = Polymer.Settings.useNativeCSSProperties; 3917 var nativeVariables = Polymer.Settings.useNativeCSSProperties;
3804 Polymer.Base._addFeature({ 3918 Polymer.Base._addFeature({
3805 _prepStyleProperties: function () { 3919 _prepStyleProperties: function () {
3806 if (!nativeVariables) { 3920 if (!nativeVariables) {
3807 this._ownStylePropertyNames = this._styles && this._styles.length ? propertyUtil s.decorateStyles(this._styles, this) : null; 3921 this._ownStylePropertyNames = this._styles && this._styles.length ? propertyUtil s.decorateStyles(this._styles, this) : null;
3808 } 3922 }
3809 }, 3923 },
3810 customStyle: null, 3924 customStyle: null,
3811 getComputedStyleValue: function (property) { 3925 getComputedStyleValue: function (property) {
3926 if (!nativeVariables && !this._styleProperties) {
3927 this._computeStyleProperties();
3928 }
3812 return !nativeVariables && this._styleProperties && this._styleProperties[proper ty] || getComputedStyle(this).getPropertyValue(property); 3929 return !nativeVariables && this._styleProperties && this._styleProperties[proper ty] || getComputedStyle(this).getPropertyValue(property);
3813 }, 3930 },
3814 _setupStyleProperties: function () { 3931 _setupStyleProperties: function () {
3815 this.customStyle = {}; 3932 this.customStyle = {};
3816 this._styleCache = null; 3933 this._styleCache = null;
3817 this._styleProperties = null; 3934 this._styleProperties = null;
3818 this._scopeSelector = null; 3935 this._scopeSelector = null;
3819 this._ownStyleProperties = null; 3936 this._ownStyleProperties = null;
3820 this._customStyle = null; 3937 this._customStyle = null;
3821 }, 3938 },
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
3986 styleDefaults.updateStyles(properties); 4103 styleDefaults.updateStyles(properties);
3987 Polymer.Base._updateRootStyles(document); 4104 Polymer.Base._updateRootStyles(document);
3988 }; 4105 };
3989 var styleCache = new Polymer.StyleCache(); 4106 var styleCache = new Polymer.StyleCache();
3990 Polymer.customStyleCache = styleCache; 4107 Polymer.customStyleCache = styleCache;
3991 var SCOPE_NAME = styleTransformer.SCOPE_NAME; 4108 var SCOPE_NAME = styleTransformer.SCOPE_NAME;
3992 var XSCOPE_NAME = propertyUtils.XSCOPE_NAME; 4109 var XSCOPE_NAME = propertyUtils.XSCOPE_NAME;
3993 }());Polymer.Base._addFeature({ 4110 }());Polymer.Base._addFeature({
3994 _registerFeatures: function () { 4111 _registerFeatures: function () {
3995 this._prepIs(); 4112 this._prepIs();
4113 if (this.factoryImpl) {
3996 this._prepConstructor(); 4114 this._prepConstructor();
4115 }
3997 this._prepStyles(); 4116 this._prepStyles();
3998 }, 4117 },
3999 _finishRegisterFeatures: function () { 4118 _finishRegisterFeatures: function () {
4000 this._prepTemplate(); 4119 this._prepTemplate();
4001 this._prepShimStyles(); 4120 this._prepShimStyles();
4002 this._prepAnnotations(); 4121 this._prepAnnotations();
4003 this._prepEffects(); 4122 this._prepEffects();
4004 this._prepBehaviors(); 4123 this._prepBehaviors();
4005 this._prepPropertyInfo(); 4124 this._prepPropertyInfo();
4006 this._prepBindings(); 4125 this._prepBindings();
4007 this._prepShady(); 4126 this._prepShady();
4008 }, 4127 },
4009 _prepBehavior: function (b) { 4128 _prepBehavior: function (b) {
4010 this._addPropertyEffects(b.properties); 4129 this._addPropertyEffects(b.properties);
4011 this._addComplexObserverEffects(b.observers); 4130 this._addComplexObserverEffects(b.observers);
4012 this._addHostAttributes(b.hostAttributes); 4131 this._addHostAttributes(b.hostAttributes);
4013 }, 4132 },
4014 _initFeatures: function () { 4133 _initFeatures: function () {
4015 this._setupGestures(); 4134 this._setupGestures();
4016 this._setupConfigure(); 4135 this._setupConfigure(this.__data__);
4017 this._setupStyleProperties(); 4136 this._setupStyleProperties();
4018 this._setupDebouncers(); 4137 this._setupDebouncers();
4019 this._setupShady(); 4138 this._setupShady();
4020 this._registerHost(); 4139 this._registerHost();
4021 if (this._template) { 4140 if (this._template) {
4022 this._validateApplyShim(); 4141 this._validateApplyShim();
4023 this._poolContent(); 4142 this._poolContent();
4024 this._beginHosting(); 4143 this._beginHosting();
4025 this._stampTemplate(); 4144 this._stampTemplate();
4026 this._endHosting(); 4145 this._endHosting();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
4098 } 4217 }
4099 var buildType = this.__cssBuild; 4218 var buildType = this.__cssBuild;
4100 var targetedBuild = styleUtil.isTargetedBuild(buildType); 4219 var targetedBuild = styleUtil.isTargetedBuild(buildType);
4101 if (settings.useNativeCSSProperties && targetedBuild) { 4220 if (settings.useNativeCSSProperties && targetedBuild) {
4102 return; 4221 return;
4103 } 4222 }
4104 var styleRules = styleUtil.rulesForStyle(e); 4223 var styleRules = styleUtil.rulesForStyle(e);
4105 if (!targetedBuild) { 4224 if (!targetedBuild) {
4106 styleUtil.forEachRule(styleRules, function (rule) { 4225 styleUtil.forEachRule(styleRules, function (rule) {
4107 styleTransformer.documentRule(rule); 4226 styleTransformer.documentRule(rule);
4227 });
4108 if (settings.useNativeCSSProperties && !buildType) { 4228 if (settings.useNativeCSSProperties && !buildType) {
4109 applyShim.transformRule(rule); 4229 applyShim.transform([e]);
4110 } 4230 }
4111 });
4112 } 4231 }
4113 if (settings.useNativeCSSProperties) { 4232 if (settings.useNativeCSSProperties) {
4114 e.textContent = styleUtil.toCssText(styleRules); 4233 e.textContent = styleUtil.toCssText(styleRules);
4115 } else { 4234 } else {
4116 var self = this; 4235 var self = this;
4117 var fn = function fn() { 4236 var fn = function fn() {
4118 self._flushCustomProperties(); 4237 self._flushCustomProperties();
4119 }; 4238 };
4120 if (initialApply) { 4239 if (initialApply) {
4121 Polymer.RenderStatus.whenReady(fn); 4240 Polymer.RenderStatus.whenReady(fn);
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
4272 kind: 'function', 4391 kind: 'function',
4273 effect: this._createForwardPropEffector(prop), 4392 effect: this._createForwardPropEffector(prop),
4274 fn: Polymer.Bind._functionEffect 4393 fn: Polymer.Bind._functionEffect
4275 }, 4394 },
4276 { 4395 {
4277 kind: 'notify', 4396 kind: 'notify',
4278 fn: Polymer.Bind._notifyEffect, 4397 fn: Polymer.Bind._notifyEffect,
4279 effect: { event: Polymer.CaseMap.camelToDashCase(parentProp) + '-changed' } 4398 effect: { event: Polymer.CaseMap.camelToDashCase(parentProp) + '-changed' }
4280 } 4399 }
4281 ]; 4400 ];
4401 proto._propertyEffects = proto._propertyEffects || {};
4402 proto._propertyEffects[parentProp] = effects;
4282 Polymer.Bind._createAccessors(proto, parentProp, effects); 4403 Polymer.Bind._createAccessors(proto, parentProp, effects);
4283 } 4404 }
4284 } 4405 }
4285 var self = this; 4406 var self = this;
4286 if (template != this) { 4407 if (template != this) {
4287 Polymer.Bind.prepareInstance(template); 4408 Polymer.Bind.prepareInstance(template);
4288 template._forwardParentProp = function (source, value) { 4409 template._forwardParentProp = function (source, value) {
4289 self._forwardParentProp(source, value); 4410 self._forwardParentProp(source, value);
4290 }; 4411 };
4291 } 4412 }
(...skipping 21 matching lines...) Expand all
4313 } 4434 }
4314 }; 4435 };
4315 }, 4436 },
4316 _extendTemplate: function (template, proto) { 4437 _extendTemplate: function (template, proto) {
4317 var n$ = Object.getOwnPropertyNames(proto); 4438 var n$ = Object.getOwnPropertyNames(proto);
4318 if (proto._propertySetter) { 4439 if (proto._propertySetter) {
4319 template._propertySetter = proto._propertySetter; 4440 template._propertySetter = proto._propertySetter;
4320 } 4441 }
4321 for (var i = 0, n; i < n$.length && (n = n$[i]); i++) { 4442 for (var i = 0, n; i < n$.length && (n = n$[i]); i++) {
4322 var val = template[n]; 4443 var val = template[n];
4444 if (val && n == '_propertyEffects') {
4445 var pe = Polymer.Base.mixin({}, val);
4446 template._propertyEffects = Polymer.Base.mixin(pe, proto._propertyEffects);
4447 } else {
4323 var pd = Object.getOwnPropertyDescriptor(proto, n); 4448 var pd = Object.getOwnPropertyDescriptor(proto, n);
4324 Object.defineProperty(template, n, pd); 4449 Object.defineProperty(template, n, pd);
4325 if (val !== undefined) { 4450 if (val !== undefined) {
4326 template._propertySetter(n, val); 4451 template._propertySetter(n, val);
4327 } 4452 }
4328 } 4453 }
4454 }
4329 }, 4455 },
4330 _showHideChildren: function (hidden) { 4456 _showHideChildren: function (hidden) {
4331 }, 4457 },
4332 _forwardInstancePath: function (inst, path, value) { 4458 _forwardInstancePath: function (inst, path, value) {
4333 }, 4459 },
4334 _forwardInstanceProp: function (inst, prop, value) { 4460 _forwardInstanceProp: function (inst, prop, value) {
4335 }, 4461 },
4336 _notifyPathUpImpl: function (path, value) { 4462 _notifyPathUpImpl: function (path, value) {
4337 var dataHost = this.dataHost; 4463 var dataHost = this.dataHost;
4338 var dot = path.indexOf('.'); 4464 var root = Polymer.Path.root(path);
4339 var root = dot < 0 ? path : path.slice(0, dot);
4340 dataHost._forwardInstancePath.call(dataHost, this, path, value); 4465 dataHost._forwardInstancePath.call(dataHost, this, path, value);
4341 if (root in dataHost._parentProps) { 4466 if (root in dataHost._parentProps) {
4342 dataHost._templatized._notifyPath(dataHost._parentPropPrefix + path, value); 4467 dataHost._templatized._notifyPath(dataHost._parentPropPrefix + path, value);
4343 } 4468 }
4344 }, 4469 },
4345 _pathEffectorImpl: function (path, value, fromAbove) { 4470 _pathEffectorImpl: function (path, value, fromAbove) {
4346 if (this._forwardParentPath) { 4471 if (this._forwardParentPath) {
4347 if (path.indexOf(this._parentPropPrefix) === 0) { 4472 if (path.indexOf(this._parentPropPrefix) === 0) {
4348 var subPath = path.substring(this._parentPropPrefix.length); 4473 var subPath = path.substring(this._parentPropPrefix.length);
4349 var model = this._modelForPath(subPath); 4474 var model = Polymer.Path.root(subPath);
4350 if (model in this._parentProps) { 4475 if (model in this._parentProps) {
4351 this._forwardParentPath(subPath, value); 4476 this._forwardParentPath(subPath, value);
4352 } 4477 }
4353 } 4478 }
4354 } 4479 }
4355 Polymer.Base._pathEffector.call(this._templatized, path, value, fromAbove); 4480 Polymer.Base._pathEffector.call(this._templatized, path, value, fromAbove);
4356 }, 4481 },
4357 _constructorImpl: function (model, host) { 4482 _constructorImpl: function (model, host) {
4358 this._rootDataHost = host._getRootDataHost(); 4483 this._rootDataHost = host._getRootDataHost();
4359 this._setupConfigure(model); 4484 this._setupConfigure(model);
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
4585 type: Function, 4710 type: Function,
4586 observer: '_filterChanged' 4711 observer: '_filterChanged'
4587 }, 4712 },
4588 observe: { 4713 observe: {
4589 type: String, 4714 type: String,
4590 observer: '_observeChanged' 4715 observer: '_observeChanged'
4591 }, 4716 },
4592 delay: Number, 4717 delay: Number,
4593 renderedItemCount: { 4718 renderedItemCount: {
4594 type: Number, 4719 type: Number,
4595 notify: true, 4720 notify: !Polymer.Settings.suppressTemplateNotifications,
4596 readOnly: true 4721 readOnly: true
4597 }, 4722 },
4598 initialCount: { 4723 initialCount: {
4599 type: Number, 4724 type: Number,
4600 observer: '_initializeChunking' 4725 observer: '_initializeChunking'
4601 }, 4726 },
4602 targetFramerate: { 4727 targetFramerate: {
4603 type: Number, 4728 type: Number,
4604 value: 20 4729 value: 20
4605 }, 4730 },
4731 notifyDomChange: { type: Boolean },
4606 _targetFrameTime: { 4732 _targetFrameTime: {
4607 type: Number, 4733 type: Number,
4608 computed: '_computeFrameTime(targetFramerate)' 4734 computed: '_computeFrameTime(targetFramerate)'
4609 } 4735 }
4610 }, 4736 },
4611 behaviors: [Polymer.Templatizer], 4737 behaviors: [Polymer.Templatizer],
4612 observers: ['_itemsChanged(items.*)'], 4738 observers: ['_itemsChanged(items.*)'],
4613 created: function () { 4739 created: function () {
4614 this._instances = []; 4740 this._instances = [];
4615 this._pool = []; 4741 this._pool = [];
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
4763 } else if (!inst.isPlaceholder && i >= this._limit) { 4889 } else if (!inst.isPlaceholder && i >= this._limit) {
4764 inst = this._downgradeInstance(i, inst.__key__); 4890 inst = this._downgradeInstance(i, inst.__key__);
4765 } 4891 }
4766 keyToIdx[inst.__key__] = i; 4892 keyToIdx[inst.__key__] = i;
4767 if (!inst.isPlaceholder) { 4893 if (!inst.isPlaceholder) {
4768 inst.__setProperty(this.indexAs, i, true); 4894 inst.__setProperty(this.indexAs, i, true);
4769 } 4895 }
4770 } 4896 }
4771 this._pool.length = 0; 4897 this._pool.length = 0;
4772 this._setRenderedItemCount(this._instances.length); 4898 this._setRenderedItemCount(this._instances.length);
4899 if (!Polymer.Settings.suppressTemplateNotifications || this.notifyDomChange) {
4773 this.fire('dom-change'); 4900 this.fire('dom-change');
4901 }
4774 this._tryRenderChunk(); 4902 this._tryRenderChunk();
4775 }, 4903 },
4776 _applyFullRefresh: function () { 4904 _applyFullRefresh: function () {
4777 var c = this.collection; 4905 var c = this.collection;
4778 var keys; 4906 var keys;
4779 if (this._sortFn) { 4907 if (this._sortFn) {
4780 keys = c ? c.getKeys() : []; 4908 keys = c ? c.getKeys() : [];
4781 } else { 4909 } else {
4782 keys = []; 4910 keys = [];
4783 var items = this.items; 4911 var items = this.items;
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
4959 } 5087 }
4960 inst = { 5088 inst = {
4961 isPlaceholder: true, 5089 isPlaceholder: true,
4962 __key__: key 5090 __key__: key
4963 }; 5091 };
4964 this._instances[idx] = inst; 5092 this._instances[idx] = inst;
4965 return inst; 5093 return inst;
4966 }, 5094 },
4967 _showHideChildren: function (hidden) { 5095 _showHideChildren: function (hidden) {
4968 for (var i = 0; i < this._instances.length; i++) { 5096 for (var i = 0; i < this._instances.length; i++) {
5097 if (!this._instances[i].isPlaceholder)
4969 this._instances[i]._showHideChildren(hidden); 5098 this._instances[i]._showHideChildren(hidden);
4970 } 5099 }
4971 }, 5100 },
4972 _forwardInstanceProp: function (inst, prop, value) { 5101 _forwardInstanceProp: function (inst, prop, value) {
4973 if (prop == this.as) { 5102 if (prop == this.as) {
4974 var idx; 5103 var idx;
4975 if (this._sortFn || this._filterFn) { 5104 if (this._sortFn || this._filterFn) {
4976 idx = this.items.indexOf(this.collection.getItem(inst.__key__)); 5105 idx = this.items.indexOf(this.collection.getItem(inst.__key__));
4977 } else { 5106 } else {
4978 idx = inst[this.indexAs]; 5107 idx = inst[this.indexAs];
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
5127 properties: { 5256 properties: {
5128 'if': { 5257 'if': {
5129 type: Boolean, 5258 type: Boolean,
5130 value: false, 5259 value: false,
5131 observer: '_queueRender' 5260 observer: '_queueRender'
5132 }, 5261 },
5133 restamp: { 5262 restamp: {
5134 type: Boolean, 5263 type: Boolean,
5135 value: false, 5264 value: false,
5136 observer: '_queueRender' 5265 observer: '_queueRender'
5137 } 5266 },
5267 notifyDomChange: { type: Boolean }
5138 }, 5268 },
5139 behaviors: [Polymer.Templatizer], 5269 behaviors: [Polymer.Templatizer],
5140 _queueRender: function () { 5270 _queueRender: function () {
5141 this._debounceTemplate(this._render); 5271 this._debounceTemplate(this._render);
5142 }, 5272 },
5143 detached: function () { 5273 detached: function () {
5144 if (!this.parentNode || this.parentNode.nodeType == Node.DOCUMENT_FRAGMENT_NODE && (!Polymer.Settings.hasShadow || !(this.parentNode instanceof ShadowRoot))) { 5274 if (!this.parentNode || this.parentNode.nodeType == Node.DOCUMENT_FRAGMENT_NODE && (!Polymer.Settings.hasShadow || !(this.parentNode instanceof ShadowRoot))) {
5145 this._teardownInstance(); 5275 this._teardownInstance();
5146 } 5276 }
5147 }, 5277 },
(...skipping 12 matching lines...) Expand all
5160 } 5290 }
5161 this._ensureInstance(); 5291 this._ensureInstance();
5162 this._showHideChildren(); 5292 this._showHideChildren();
5163 } else if (this.restamp) { 5293 } else if (this.restamp) {
5164 this._teardownInstance(); 5294 this._teardownInstance();
5165 } 5295 }
5166 if (!this.restamp && this._instance) { 5296 if (!this.restamp && this._instance) {
5167 this._showHideChildren(); 5297 this._showHideChildren();
5168 } 5298 }
5169 if (this.if != this._lastIf) { 5299 if (this.if != this._lastIf) {
5300 if (!Polymer.Settings.suppressTemplateNotifications || this.notifyDomChange) {
5170 this.fire('dom-change'); 5301 this.fire('dom-change');
5302 }
5171 this._lastIf = this.if; 5303 this._lastIf = this.if;
5172 } 5304 }
5173 }, 5305 },
5174 _ensureInstance: function () { 5306 _ensureInstance: function () {
5175 var parentNode = Polymer.dom(this).parentNode; 5307 var parentNode = Polymer.dom(this).parentNode;
5176 if (parentNode) { 5308 if (parentNode) {
5177 var parent = Polymer.dom(parentNode); 5309 var parent = Polymer.dom(parentNode);
5178 if (!this._instance) { 5310 if (!this._instance) {
5179 this._instance = this.stamp(); 5311 this._instance = this.stamp();
5180 var root = this._instance.root; 5312 var root = this._instance.root;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
5215 this._instance.__setProperty(prop, value, true); 5347 this._instance.__setProperty(prop, value, true);
5216 } 5348 }
5217 }, 5349 },
5218 _forwardParentPath: function (path, value) { 5350 _forwardParentPath: function (path, value) {
5219 if (this._instance) { 5351 if (this._instance) {
5220 this._instance._notifyPath(path, value, true); 5352 this._instance._notifyPath(path, value, true);
5221 } 5353 }
5222 } 5354 }
5223 });Polymer({ 5355 });Polymer({
5224 is: 'dom-bind', 5356 is: 'dom-bind',
5357 properties: { notifyDomChange: { type: Boolean } },
5225 extends: 'template', 5358 extends: 'template',
5226 _template: null, 5359 _template: null,
5227 created: function () { 5360 created: function () {
5228 var self = this; 5361 var self = this;
5229 Polymer.RenderStatus.whenReady(function () { 5362 Polymer.RenderStatus.whenReady(function () {
5230 if (document.readyState == 'loading') { 5363 if (document.readyState == 'loading') {
5231 document.addEventListener('DOMContentLoaded', function () { 5364 document.addEventListener('DOMContentLoaded', function () {
5232 self._markImportsReady(); 5365 self._markImportsReady();
5233 }); 5366 });
5234 } else { 5367 } else {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
5295 this._prepAnnotations(); 5428 this._prepAnnotations();
5296 this._prepEffects(); 5429 this._prepEffects();
5297 this._prepBehaviors(); 5430 this._prepBehaviors();
5298 this._prepConfigure(); 5431 this._prepConfigure();
5299 this._prepBindings(); 5432 this._prepBindings();
5300 this._prepPropertyInfo(); 5433 this._prepPropertyInfo();
5301 Polymer.Base._initFeatures.call(this); 5434 Polymer.Base._initFeatures.call(this);
5302 this._children = Polymer.TreeApi.arrayCopyChildNodes(this.root); 5435 this._children = Polymer.TreeApi.arrayCopyChildNodes(this.root);
5303 } 5436 }
5304 this._insertChildren(); 5437 this._insertChildren();
5438 if (!Polymer.Settings.suppressTemplateNotifications || this.notifyDomChange) {
5305 this.fire('dom-change'); 5439 this.fire('dom-change');
5306 } 5440 }
5441 }
5307 }); 5442 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698