This repository was archived by the owner on Apr 26, 2019. It is now read-only.
forked from Polymer/polymer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpolymer.js
More file actions
11870 lines (10815 loc) · 412 KB
/
polymer.js
File metadata and controls
11870 lines (10815 loc) · 412 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // identity function for calling harmony imports with the correct context
/******/ __webpack_require__.i = function(value) { return value; };
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 41);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports) {
/*__wc__loader*/
(function() {
'use strict';
const userPolymer = window.Polymer;
/**
* @namespace Polymer
* @summary Polymer is a lightweight library built on top of the web
* standards-based Web Components API's, and makes it easy to build your
* own custom HTML elements.
* @param {Object} info Prototype for the custom element. It must contain
* an `is` property to specify the element name. Other properties populate
* the element prototype. The `properties`, `observers`, `hostAttributes`,
* and `listeners` properties are processed to create element features.
* @return {Object} Returns a custom element class for the given provided
* prototype `info` object. The name of the element if given by `info.is`.
*/
window.Polymer = function(info) {
return window.Polymer._polymerFn(info);
}
// support user settings on the Polymer object
if (userPolymer) {
Object.assign(Polymer, userPolymer);
}
// To be plugged by legacy implementation if loaded
/**
* @param {Object} info Prototype for the custom element. It must contain
* an `is` property to specify the element name. Other properties populate
* the element prototype. The `properties`, `observers`, `hostAttributes`,
* and `listeners` properties are processed to create element features.
*/
window.Polymer._polymerFn = function(info) { // eslint-disable-line no-unused-vars
throw new Error('Load polymer.html to use the Polymer() function.');
}
window.Polymer.version = '2.0.1';
/* eslint-disable no-unused-vars */
/*
When using Closure Compiler, JSCompiler_renameProperty(property, object) is replaced by the munged name for object[property]
We cannot alias this function, so we have to use a small shim that has the same behavior when not compiling.
*/
window.JSCompiler_renameProperty = function(prop, obj) {
return prop;
}
/* eslint-enable */
})();
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
/*__wc__loader*/
__webpack_require__(0);
(function() {
'use strict';
// unique global id for deduping mixins.
let dedupeId = 0;
/**
* Given a mixin producing function, memoize applications of mixin to base
* @private
* @param {Function} mixin Mixin for which to create a caching mixin.
* @return {Function} Returns a mixin which when applied multiple times to the
* same base will always return the same extended class.
*/
function cachingMixin(mixin) {
return function(base) {
if (!mixin.__mixinApplications) {
mixin.__mixinApplications = new WeakMap();
}
let map = mixin.__mixinApplications;
let application = map.get(base);
if (!application) {
application = mixin(base);
map.set(base, application);
}
return application;
};
}
/**
* Wraps an ES6 class expression mixin such that the mixin is only applied
* if it has not already been applied its base argument. Also memoizes mixin
* applications.
*
* @memberof Polymer
* @param {Function} mixin ES6 class expression mixin to wrap
* @return {Function} Wrapped mixin that deduplicates and memoizes
* mixin applications to base
*/
Polymer.dedupingMixin = function(mixin) {
mixin = cachingMixin(mixin);
// maintain a unique id for each mixin
mixin.__dedupeId = ++dedupeId;
return function(base) {
let baseSet = base.__mixinSet;
if (baseSet && baseSet[mixin.__dedupeId]) {
return base;
}
let extended = mixin(base);
// copy inherited mixin set from the extended class, or the base class
// NOTE: we avoid use of Set here because some browser (IE11)
// cannot extend a base Set via the constructor.
extended.__mixinSet =
Object.create(extended.__mixinSet || baseSet || null);
extended.__mixinSet[mixin.__dedupeId] = true;
return extended;
}
};
})();
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
/*__wc__loader*/
__webpack_require__(1);
(function() {
'use strict';
// Common implementation for mixin & behavior
function mutablePropertyChange(inst, property, value, old, mutableData) {
let isObject;
if (mutableData) {
isObject = (typeof value === 'object' && value !== null);
// Pull `old` for Objects from temp cache, but treat `null` as a primitive
if (isObject) {
old = inst.__dataTemp[property];
}
}
// Strict equality check, but return false for NaN===NaN
let shouldChange = (old !== value && (old === old || value === value));
// Objects are stored in temporary cache (cleared at end of
// turn), which is used for dirty-checking
if (isObject && shouldChange) {
inst.__dataTemp[property] = value;
}
return shouldChange;
}
/**
* Element class mixin to skip strict dirty-checking for objects and arrays
* (always consider them to be "dirty"), for use on elements utilizing
* `Polymer.PropertyEffects`
*
* By default, `Polymer.PropertyEffects` performs strict dirty checking on
* objects, which means that any deep modifications to an object or array will
* not be propagated unless "immutable" data patterns are used (i.e. all object
* references from the root to the mutation were changed).
*
* Polymer also provides a proprietary data mutation and path notification API
* (e.g. `notifyPath`, `set`, and array mutation API's) that allow efficient
* mutation and notification of deep changes in an object graph to all elements
* bound to the same object graph.
*
* In cases where neither immutable patterns nor the data mutation API can be
* used, applying this mixin will cause Polymer to skip dirty checking for
* objects and arrays (always consider them to be "dirty"). This allows a
* user to make a deep modification to a bound object graph, and then either
* simply re-set the object (e.g. `this.items = this.items`) or call `notifyPath`
* (e.g. `this.notifyPath('items')`) to update the tree. Note that all
* elements that wish to be updated based on deep mutations must apply this
* mixin or otherwise skip strict dirty checking for objects/arrays.
*
* In order to make the dirty check strategy configurable, see
* `Polymer.OptionalMutableData`.
*
* Note, the performance characteristics of propagating large object graphs
* will be worse as opposed to using strict dirty checking with immutable
* patterns or Polymer's path notification API.
*
* @polymerMixin
* @memberof Polymer
* @summary Element class mixin to skip strict dirty-checking for objects
* and arrays
*/
Polymer.MutableData = Polymer.dedupingMixin(superClass => {
/**
* @polymerMixinClass
* @implements {Polymer_MutableData}
*/
class MutableData extends superClass {
/**
* Overrides `Polymer.PropertyEffects` to provide option for skipping
* strict equality checking for Objects and Arrays.
*
* This method pulls the value to dirty check against from the `__dataTemp`
* cache (rather than the normal `__data` cache) for Objects. Since the temp
* cache is cleared at the end of a turn, this implementation allows
* side-effects of deep object changes to be processed by re-setting the
* same object (using the temp cache as an in-turn backstop to prevent
* cycles due to 2-way notification).
*
* @param {string} property Property name
* @param {*} value New property value
* @param {*} old Previous property value
* @return {boolean} Whether the property should be considered a change
* @protected
*/
_shouldPropertyChange(property, value, old) {
return mutablePropertyChange(this, property, value, old, true);
}
}
return MutableData;
});
/**
* Element class mixin to add the optional ability to skip strict
* dirty-checking for objects and arrays (always consider them to be
* "dirty") by setting a `mutable-data` attribute on an element instance.
*
* By default, `Polymer.PropertyEffects` performs strict dirty checking on
* objects, which means that any deep modifications to an object or array will
* not be propagated unless "immutable" data patterns are used (i.e. all object
* references from the root to the mutation were changed).
*
* Polymer also provides a proprietary data mutation and path notification API
* (e.g. `notifyPath`, `set`, and array mutation API's) that allow efficient
* mutation and notification of deep changes in an object graph to all elements
* bound to the same object graph.
*
* In cases where neither immutable patterns nor the data mutation API can be
* used, applying this mixin will allow Polymer to skip dirty checking for
* objects and arrays (always consider them to be "dirty"). This allows a
* user to make a deep modification to a bound object graph, and then either
* simply re-set the object (e.g. `this.items = this.items`) or call `notifyPath`
* (e.g. `this.notifyPath('items')`) to update the tree. Note that all
* elements that wish to be updated based on deep mutations must apply this
* mixin or otherwise skip strict dirty checking for objects/arrays.
*
* While this mixin adds the ability to forgo Object/Array dirty checking,
* the `mutableData` flag defaults to false and must be set on the instance.
*
* Note, the performance characteristics of propagating large object graphs
* will be worse by relying on `mutableData: true` as opposed to using
* strict dirty checking with immutable patterns or Polymer's path notification
* API.
*
* @polymerMixin
* @memberof Polymer
* @summary Element class mixin to optionally skip strict dirty-checking
* for objects and arrays
*/
Polymer.OptionalMutableData = Polymer.dedupingMixin(superClass => {
/**
* @polymerMixinClass
* @implements {Polymer_OptionalMutableData}
*/
class OptionalMutableData extends superClass {
static get properties() {
return {
/**
* Instance-level flag for configuring the dirty-checking strategy
* for this element. When true, Objects and Arrays will skip dirty
* checking, otherwise strict equality checking will be used.
*/
mutableData: Boolean
};
}
/**
* Overrides `Polymer.PropertyEffects` to provide option for skipping
* strict equality checking for Objects and Arrays.
*
* When `this.mutableData` is true on this instance, this method
* pulls the value to dirty check against from the `__dataTemp` cache
* (rather than the normal `__data` cache) for Objects. Since the temp
* cache is cleared at the end of a turn, this implementation allows
* side-effects of deep object changes to be processed by re-setting the
* same object (using the temp cache as an in-turn backstop to prevent
* cycles due to 2-way notification).
*
* @param {string} property Property name
* @param {*} value New property value
* @param {*} old Previous property value
* @return {boolean} Whether the property should be considered a change
* @protected
*/
_shouldPropertyChange(property, value, old) {
return mutablePropertyChange(this, property, value, old, this.mutableData);
}
}
return OptionalMutableData;
});
// Export for use by legacy behavior
Polymer.MutableData._mutablePropertyChange = mutablePropertyChange;
})();
/***/ }),
/* 3 */
/***/ (function(module, exports, __webpack_require__) {
/*__wc__loader*/
__webpack_require__(0);
(function() {
'use strict';
/** @typedef {{run: function(function(), number=):number, cancel: function(number)}} */
let AsyncInterface; // eslint-disable-line no-unused-vars
// Microtask implemented using Mutation Observer
let microtaskCurrHandle = 0;
let microtaskLastHandle = 0;
let microtaskCallbacks = [];
let microtaskNodeContent = 0;
let microtaskNode = document.createTextNode('');
new window.MutationObserver(microtaskFlush).observe(microtaskNode, {characterData: true});
function microtaskFlush() {
const len = microtaskCallbacks.length;
for (let i = 0; i < len; i++) {
let cb = microtaskCallbacks[i];
if (cb) {
try {
cb();
} catch (e) {
setTimeout(() => { throw e });
}
}
}
microtaskCallbacks.splice(0, len);
microtaskLastHandle += len;
}
/**
* Module that provides a number of strategies for enqueuing asynchronous
* tasks. Each sub-module provides a standard `run(fn)` interface that returns a
* handle, and a `cancel(handle)` interface for canceling async tasks before
* they run.
*
* @namespace
* @memberof Polymer
* @summary Module that provides a number of strategies for enqueuing asynchronous
* tasks.
*/
Polymer.Async = {
/**
* Async interface wrapper around `setTimeout`.
*
* @namespace
* @memberof Polymer.Async
* @summary Async interface wrapper around `setTimeout`.
*/
timeOut: {
/**
* Returns a sub-module with the async interface providing the provided
* delay.
*
* @memberof Polymer.Async.timeOut
* @param {number} delay Time to wait before calling callbacks in ms
* @return {AsyncInterface} An async timeout interface
*/
after(delay) {
return {
run(fn) { return setTimeout(fn, delay) },
cancel: window.clearTimeout.bind(window)
}
},
/**
* Enqueues a function called in the next task.
*
* @memberof Polymer.Async.timeOut
* @param {Function} fn Callback to run
* @return {number} Handle used for canceling task
*/
run: window.setTimeout.bind(window),
/**
* Cancels a previously enqueued `timeOut` callback.
*
* @memberof Polymer.Async.timeOut
* @param {number} handle Handle returned from `run` of callback to cancel
*/
cancel: window.clearTimeout.bind(window)
},
/**
* Async interface wrapper around `requestAnimationFrame`.
*
* @namespace
* @memberof Polymer.Async
* @summary Async interface wrapper around `requestAnimationFrame`.
*/
animationFrame: {
/**
* Enqueues a function called at `requestAnimationFrame` timing.
*
* @memberof Polymer.Async.animationFrame
* @param {Function} fn Callback to run
* @return {number} Handle used for canceling task
*/
run: window.requestAnimationFrame.bind(window),
/**
* Cancels a previously enqueued `animationFrame` callback.
*
* @memberof Polymer.Async.timeOut
* @param {number} handle Handle returned from `run` of callback to cancel
*/
cancel: window.cancelAnimationFrame.bind(window)
},
/**
* Async interface wrapper around `requestIdleCallback`. Falls back to
* `setTimeout` on browsers that do not support `requestIdleCallback`.
*
* @namespace
* @memberof Polymer.Async
* @summary Async interface wrapper around `requestIdleCallback`.
*/
idlePeriod: {
/**
* Enqueues a function called at `requestIdleCallback` timing.
*
* @memberof Polymer.Async.idlePeriod
* @param {function(IdleDeadline)} fn Callback to run
* @return {number} Handle used for canceling task
*/
run(fn) {
return window.requestIdleCallback ?
window.requestIdleCallback(fn) :
window.setTimeout(fn, 16);
},
/**
* Cancels a previously enqueued `idlePeriod` callback.
*
* @memberof Polymer.Async.idlePeriod
* @param {number} handle Handle returned from `run` of callback to cancel
*/
cancel(handle) {
window.cancelIdleCallback ?
window.cancelIdleCallback(handle) :
window.clearTimeout(handle);
}
},
/**
* Async interface for enqueueing callbacks that run at microtask timing.
*
* Note that microtask timing is achieved via a single `MutationObserver`,
* and thus callbacks enqueued with this API will all run in a single
* batch, and not interleaved with other microtasks such as promises.
* Promises are avoided as an implementation choice for the time being
* due to Safari bugs that cause Promises to lack microtask guarantees.
*
* @namespace
* @memberof Polymer.Async
* @summary Async interface for enqueueing callbacks that run at microtask
* timing.
*/
microTask: {
/**
* Enqueues a function called at microtask timing.
*
* @memberof Polymer.Async.microTask
* @param {Function} callback Callback to run
* @return {*} Handle used for canceling task
*/
run(callback) {
microtaskNode.textContent = microtaskNodeContent++;
microtaskCallbacks.push(callback);
return microtaskCurrHandle++;
},
/**
* Cancels a previously enqueued `microTask` callback.
*
* @memberof Polymer.Async.microTask
* @param {number} handle Handle returned from `run` of callback to cancel
*/
cancel(handle) {
const idx = handle - microtaskLastHandle;
if (idx >= 0) {
if (!microtaskCallbacks[idx]) {
throw new Error('invalid async handle: ' + handle);
}
microtaskCallbacks[idx] = null;
}
}
}
};
})();
/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {
/*__wc__loader*/
__webpack_require__(0);
(function() {
'use strict';
let CSS_URL_RX = /(url\()([^)]*)(\))/g;
let ABS_URL = /(^\/)|(^#)|(^[\w-\d]*:)/;
let workingURL;
let resolveDoc;
/**
* Resolves the given URL against the provided `baseUri'.
*
* @memberof Polymer.ResolveUrl
* @param {string} url Input URL to resolve
* @param {string} baseURI Base URI to resolve the URL against
* @return {string} resolved URL
*/
function resolveUrl(url, baseURI) {
if (url && ABS_URL.test(url)) {
return url;
}
// Lazy feature detection.
if (workingURL === undefined) {
workingURL = false;
try {
const u = new URL('b', 'http://a');
u.pathname = 'c%20d';
workingURL = (u.href === 'http://a/c%20d');
} catch (e) {
// silently fail
}
}
if (!baseURI) {
baseURI = document.baseURI || window.location.href;
}
if (workingURL) {
return (new URL(url, baseURI)).href;
}
// Fallback to creating an anchor into a disconnected document.
if (!resolveDoc) {
resolveDoc = document.implementation.createHTMLDocument('temp');
resolveDoc.base = resolveDoc.createElement('base');
resolveDoc.head.appendChild(resolveDoc.base);
resolveDoc.anchor = resolveDoc.createElement('a');
resolveDoc.body.appendChild(resolveDoc.anchor);
}
resolveDoc.base.href = baseURI;
resolveDoc.anchor.href = url;
return resolveDoc.anchor.href || url;
}
/**
* Resolves any relative URL's in the given CSS text against the provided
* `ownerDocument`'s `baseURI`.
*
* @memberof Polymer.ResolveUrl
* @param {string} cssText CSS text to process
* @param {string} baseURI Base URI to resolve the URL against
* @return {string} Processed CSS text with resolved URL's
*/
function resolveCss(cssText, baseURI) {
return cssText.replace(CSS_URL_RX, function(m, pre, url, post) {
return pre + '\'' +
resolveUrl(url.replace(/["']/g, ''), baseURI) +
'\'' + post;
});
}
/**
* Returns a path from a given `url`. The path includes the trailing
* `/` from the url.
*
* @memberof Polymer.ResolveUrl
* @param {string} url Input URL to transform
* @return {string} resolved path
*/
function pathFromUrl(url) {
return url.substring(0, url.lastIndexOf('/') + 1);
}
/**
* Module with utilities for resolving relative URL's.
*
* @namespace
* @memberof Polymer
* @summary Module with utilities for resolving relative URL's.
*/
Polymer.ResolveUrl = {
resolveCss: resolveCss,
resolveUrl: resolveUrl,
pathFromUrl: pathFromUrl
};
})();
/***/ }),
/* 5 */
/***/ (function(module, exports, __webpack_require__) {
/*__wc__loader*/
__webpack_require__(0);
__webpack_require__(1);
__webpack_require__(36);
__webpack_require__(6);
__webpack_require__(31);
__webpack_require__(32);
(function() {
'use strict';
/** @const {Object} */
const CaseMap = Polymer.CaseMap;
// Monotonically increasing unique ID used for de-duping effects triggered
// from multiple properties in the same turn
let dedupeId = 0;
// Property effect types; effects are stored on the prototype using these keys
const TYPES = {
COMPUTE: '__computeEffects',
REFLECT: '__reflectEffects',
NOTIFY: '__notifyEffects',
PROPAGATE: '__propagateEffects',
OBSERVE: '__observeEffects',
READ_ONLY: '__readOnly'
}
/**
* Ensures that the model has an own-property map of effects for the given type.
* The model may be a prototype or an instance.
*
* Property effects are stored as arrays of effects by property in a map,
* by named type on the model. e.g.
*
* __computeEffects: {
* foo: [ ... ],
* bar: [ ... ]
* }
*
* If the model does not yet have an effect map for the type, one is created
* and returned. If it does, but it is not an own property (i.e. the
* prototype had effects), the the map is deeply cloned and the copy is
* set on the model and returned, ready for new effects to be added.
*
* @param {Object} model Prototype or instance
* @param {string} type Property effect type
* @return {Object} The own-property map of effects for the given type
* @private
*/
function ensureOwnEffectMap(model, type) {
let effects = model[type];
if (!effects) {
effects = model[type] = {};
} else if (!model.hasOwnProperty(type)) {
effects = model[type] = Object.create(model[type]);
for (let p in effects) {
let protoFx = effects[p];
let instFx = effects[p] = Array(protoFx.length);
for (let i=0; i<protoFx.length; i++) {
instFx[i] = protoFx[i];
}
}
}
return effects;
}
// -- effects ----------------------------------------------
/**
* Runs all effects of a given type for the given set of property changes
* on an instance.
*
* @param {Object} inst The instance with effects to run
* @param {Object} effects Object map of property-to-Array of effects
* @param {Object} props Bag of current property changes
* @param {Object=} oldProps Bag of previous values for changed properties
* @param {boolean=} hasPaths True with `props` contains one or more paths
* @param {*=} extraArgs Additional metadata to pass to effect function
* @return {boolean} True if an effect ran for this property
* @private
*/
function runEffects(inst, effects, props, oldProps, hasPaths, extraArgs) {
if (effects) {
let ran = false;
let id = dedupeId++;
for (let prop in props) {
if (runEffectsForProperty(inst, effects, id, prop, props, oldProps, hasPaths, extraArgs)) {
ran = true;
}
}
return ran;
}
return false;
}
/**
* Runs a list of effects for a given property.
*
* @param {Object} inst The instance with effects to run
* @param {Object} effects Object map of property-to-Array of effects
* @param {number} dedupeId Counter used for de-duping effects
* @param {string} prop Name of changed property
* @param {*} props Changed properties
* @param {*} oldProps Old properties
* @param {boolean=} hasPaths True with `props` contains one or more paths
* @param {*=} extraArgs Additional metadata to pass to effect function
* @return {boolean} True if an effect ran for this property
* @private
*/
function runEffectsForProperty(inst, effects, dedupeId, prop, props, oldProps, hasPaths, extraArgs) {
let ran = false;
let rootProperty = hasPaths ? Polymer.Path.root(prop) : prop;
let fxs = effects[rootProperty];
if (fxs) {
for (let i=0, l=fxs.length, fx; (i<l) && (fx=fxs[i]); i++) {
if ((!fx.info || fx.info.lastRun !== dedupeId) &&
(!hasPaths || pathMatchesTrigger(prop, fx.trigger))) {
if (fx.info) {
fx.info.lastRun = dedupeId;
}
fx.fn(inst, prop, props, oldProps, fx.info, hasPaths, extraArgs);
ran = true;
}
}
}
return ran;
}
/**
* Determines whether a property/path that has changed matches the trigger
* criteria for an effect. A trigger is a descriptor with the following
* structure, which matches the descriptors returned from `parseArg`.
* e.g. for `foo.bar.*`:
* ```
* trigger: {
* name: 'a.b',
* structured: true,
* wildcard: true
* }
* ```
* If no trigger is given, the path is deemed to match.
*
* @param {string} path Path or property that changed
* @param {Object} trigger Descriptor
* @return {boolean} Whether the path matched the trigger
*/
function pathMatchesTrigger(path, trigger) {
if (trigger) {
let triggerPath = trigger.name;
return (triggerPath == path) ||
(trigger.structured && Polymer.Path.isAncestor(triggerPath, path)) ||
(trigger.wildcard && Polymer.Path.isDescendant(triggerPath, path));
} else {
return true;
}
}
/**
* Implements the "observer" effect.
*
* Calls the method with `info.methodName` on the instance, passing the
* new and old values.
*
* @param {Object} inst The instance the effect will be run on
* @param {string} property Name of property
* @param {Object} props Bag of current property changes
* @param {Object} oldProps Bag of previous values for changed properties
* @param {Object} info Effect metadata
* @private
*/
function runObserverEffect(inst, property, props, oldProps, info) {
let fn = inst[info.methodName];
let changedProp = info.property;
if (fn) {
fn.call(inst, inst.__data[changedProp], oldProps[changedProp]);
} else if (!info.dynamicFn) {
console.warn('observer method `' + info.methodName + '` not defined');
}
}
/**
* Runs "notify" effects for a set of changed properties.
*
* This method differs from the generic `runEffects` method in that it
* will dispatch path notification events in the case that the property
* changed was a path and the root property for that path didn't have a
* "notify" effect. This is to maintain 1.0 behavior that did not require
* `notify: true` to ensure object sub-property notifications were
* sent.
*
* @param {Element} inst The instance with effects to run
* @param {Object} notifyProps Bag of properties to notify
* @param {Object} props Bag of current property changes
* @param {Object} oldProps Bag of previous values for changed properties
* @param {boolean} hasPaths True with `props` contains one or more paths
* @private
*/
function runNotifyEffects(inst, notifyProps, props, oldProps, hasPaths) {
// Notify
let fxs = inst.__notifyEffects;
let notified;
let id = dedupeId++;
// Try normal notify effects; if none, fall back to try path notification
for (let prop in notifyProps) {
if (notifyProps[prop]) {
if (fxs && runEffectsForProperty(inst, fxs, id, prop, props, oldProps, hasPaths)) {
notified = true;
} else if (hasPaths && notifyPath(inst, prop, props)) {
notified = true;
}
}
}
// Flush host if we actually notified and host was batching
// And the host has already initialized clients; this prevents
// an issue with a host observing data changes before clients are ready.
let host;
if (notified && (host = inst.__dataHost) && host._invalidateProperties) {
host._invalidateProperties();
}
}
/**
* Dispatches {property}-changed events with path information in the detail
* object to indicate a sub-path of the property was changed.
*
* @param {Element} inst The element from which to fire the event
* @param {string} path The path that was changed
* @param {Object} props Bag of current property changes
* @return {boolean} Returns true if the path was notified
* @private
*/
function notifyPath(inst, path, props) {
let rootProperty = Polymer.Path.root(path);
if (rootProperty !== path) {
let eventName = Polymer.CaseMap.camelToDashCase(rootProperty) + '-changed';
dispatchNotifyEvent(inst, eventName, props[path], path);
return true;
}
}
/**
* Dispatches {property}-changed events to indicate a property (or path)
* changed.
*
* @param {Element} inst The element from which to fire the event
* @param {string} eventName The name of the event to send ('{property}-changed')
* @param {*} value The value of the changed property
* @param {string | null | undefined} path If a sub-path of this property changed, the path
* that changed (optional).
* @private
*/
function dispatchNotifyEvent(inst, eventName, value, path) {
let detail = {
value: value,
queueProperty: true
};
if (path) {
detail.path = path;
}
inst.dispatchEvent(new CustomEvent(eventName, { detail }));
}
/**
* Implements the "notify" effect.
*
* Dispatches a non-bubbling event named `info.eventName` on the instance
* with a detail object containing the new `value`.
*
* @param {Element} inst The instance the effect will be run on
* @param {string} property Name of property
* @param {Object} props Bag of current property changes
* @param {Object} oldProps Bag of previous values for changed properties
* @param {Object} info Effect metadata
* @param {boolean} hasPaths True with `props` contains one or more paths
* @private
*/
function runNotifyEffect(inst, property, props, oldProps, info, hasPaths) {
let rootProperty = hasPaths ? Polymer.Path.root(property) : property;
let path = rootProperty != property ? property : null;
let value = path ? Polymer.Path.get(inst, path) : inst.__data[property];
if (path && value === undefined) {
value = props[property]; // specifically for .splices
}
dispatchNotifyEvent(inst, info.eventName, value, path);
}
/**
* Handler function for 2-way notification events. Receives context
* information captured in the `addNotifyListener` closure from the
* `__notifyListeners` metadata.