polymer-rails 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/polymer/polymer-micro.html +529 -0
- data/app/assets/javascripts/polymer/polymer-mini.html +40 -5
- data/app/assets/javascripts/polymer/polymer.html +79 -55
- data/app/assets/javascripts/webcomponentsjs/webcomponents-lite.js +39 -43
- data/app/assets/javascripts/webcomponentsjs/webcomponents.js +39 -43
- data/lib/polymer-rails/version.rb +1 -1
- metadata +2 -2
@@ -426,6 +426,8 @@ var getInnerHTML = Polymer.domInnerHTML.getInnerHTML;
|
|
426
426
|
var nativeInsertBefore = Element.prototype.insertBefore;
|
427
427
|
var nativeRemoveChild = Element.prototype.removeChild;
|
428
428
|
var nativeAppendChild = Element.prototype.appendChild;
|
429
|
+
var nativeCloneNode = Element.prototype.cloneNode;
|
430
|
+
var nativeImportNode = Document.prototype.importNode;
|
429
431
|
var dirtyRoots = [];
|
430
432
|
var DomApi = function (node) {
|
431
433
|
this.node = node;
|
@@ -554,8 +556,8 @@ return parentNeedsDist || hasContent && !wrappedContent;
|
|
554
556
|
},
|
555
557
|
_tryRemoveUndistributedNode: function (node) {
|
556
558
|
if (this.node.shadyRoot) {
|
557
|
-
if (node.
|
558
|
-
nativeRemoveChild.call(node.
|
559
|
+
if (node._composedParent) {
|
560
|
+
nativeRemoveChild.call(node._composedParent, node);
|
559
561
|
}
|
560
562
|
return true;
|
561
563
|
}
|
@@ -564,7 +566,7 @@ _updateInsertionPoints: function (host) {
|
|
564
566
|
host.shadyRoot._insertionPoints = factory(host.shadyRoot).querySelectorAll(CONTENT);
|
565
567
|
},
|
566
568
|
_nodeIsInLogicalTree: function (node) {
|
567
|
-
return Boolean(node._lightParent || node._isShadyRoot || this._ownerShadyRootForNode(node) || node.shadyRoot);
|
569
|
+
return Boolean(node._lightParent !== undefined || node._isShadyRoot || this._ownerShadyRootForNode(node) || node.shadyRoot);
|
568
570
|
},
|
569
571
|
_parentNeedsDistribution: function (parent) {
|
570
572
|
return parent && parent.shadyRoot && hasInsertionPoint(parent.shadyRoot);
|
@@ -737,6 +739,31 @@ _distributeParent: function () {
|
|
737
739
|
if (this._parentNeedsDistribution(this.parentNode)) {
|
738
740
|
this._lazyDistribute(this.parentNode);
|
739
741
|
}
|
742
|
+
},
|
743
|
+
cloneNode: function (deep) {
|
744
|
+
var n = nativeCloneNode.call(this.node, false);
|
745
|
+
if (deep) {
|
746
|
+
var c$ = this.childNodes;
|
747
|
+
var d = factory(n);
|
748
|
+
for (var i = 0, nc; i < c$.length; i++) {
|
749
|
+
nc = factory(c$[i]).cloneNode(true);
|
750
|
+
d.appendChild(nc);
|
751
|
+
}
|
752
|
+
}
|
753
|
+
return n;
|
754
|
+
},
|
755
|
+
importNode: function (externalNode, deep) {
|
756
|
+
var doc = this.node instanceof HTMLDocument ? this.node : this.node.ownerDocument;
|
757
|
+
var n = nativeImportNode.call(doc, externalNode, false);
|
758
|
+
if (deep) {
|
759
|
+
var c$ = factory(externalNode).childNodes;
|
760
|
+
var d = factory(n);
|
761
|
+
for (var i = 0, nc; i < c$.length; i++) {
|
762
|
+
nc = factory(doc).importNode(c$[i], true);
|
763
|
+
d.appendChild(nc);
|
764
|
+
}
|
765
|
+
}
|
766
|
+
return n;
|
740
767
|
}
|
741
768
|
};
|
742
769
|
Object.defineProperty(DomApi.prototype, 'classList', {
|
@@ -885,8 +912,9 @@ if (this.node.nodeType !== Node.TEXT_NODE) {
|
|
885
912
|
this._clear();
|
886
913
|
var d = document.createElement('div');
|
887
914
|
d.innerHTML = text;
|
888
|
-
|
889
|
-
|
915
|
+
var c$ = Array.prototype.slice.call(d.childNodes);
|
916
|
+
for (var i = 0; i < c$.length; i++) {
|
917
|
+
this.appendChild(c$[i]);
|
890
918
|
}
|
891
919
|
}
|
892
920
|
},
|
@@ -909,6 +937,13 @@ return n;
|
|
909
937
|
n = n.parentNode;
|
910
938
|
}
|
911
939
|
};
|
940
|
+
DomApi.prototype.cloneNode = function (deep) {
|
941
|
+
return this.node.cloneNode(deep);
|
942
|
+
};
|
943
|
+
DomApi.prototype.importNode = function (externalNode, deep) {
|
944
|
+
var doc = this.node instanceof HTMLDocument ? this.node : this.node.ownerDocument;
|
945
|
+
return doc.importNode(externalNode, deep);
|
946
|
+
};
|
912
947
|
DomApi.prototype.getDestinationInsertionPoints = function () {
|
913
948
|
var n$ = this.node.getDestinationInsertionPoints();
|
914
949
|
return n$ ? Array.prototype.slice.call(n$) : [];
|
@@ -416,6 +416,7 @@ var MOUSE_EVENTS = [
|
|
416
416
|
'mouseup',
|
417
417
|
'click'
|
418
418
|
];
|
419
|
+
var IS_TOUCH_ONLY = navigator.userAgent.match(/iP(?:[oa]d|hone)|Android/);
|
419
420
|
var mouseCanceller = function (mouseEvent) {
|
420
421
|
mouseEvent[HANDLED_OBJ] = { skip: true };
|
421
422
|
if (mouseEvent.type === 'click') {
|
@@ -440,6 +441,9 @@ document.removeEventListener(en, mouseCanceller, true);
|
|
440
441
|
}
|
441
442
|
}
|
442
443
|
function ignoreMouse() {
|
444
|
+
if (IS_TOUCH_ONLY) {
|
445
|
+
return;
|
446
|
+
}
|
443
447
|
if (!POINTERSTATE.mouse.mouseIgnoreJob) {
|
444
448
|
setupTeardownMouseCanceller(true);
|
445
449
|
}
|
@@ -488,6 +492,12 @@ node = next;
|
|
488
492
|
}
|
489
493
|
return node;
|
490
494
|
},
|
495
|
+
findOriginalTarget: function (ev) {
|
496
|
+
if (ev.path) {
|
497
|
+
return ev.path[0];
|
498
|
+
}
|
499
|
+
return ev.target;
|
500
|
+
},
|
491
501
|
handleNative: function (ev) {
|
492
502
|
var handled;
|
493
503
|
var type = ev.type;
|
@@ -572,12 +582,18 @@ node[GESTURE_KEY] = gobj = {};
|
|
572
582
|
}
|
573
583
|
for (var i = 0, dep, gd; i < deps.length; i++) {
|
574
584
|
dep = deps[i];
|
585
|
+
if (IS_TOUCH_ONLY && MOUSE_EVENTS.indexOf(dep) > -1) {
|
586
|
+
continue;
|
587
|
+
}
|
575
588
|
gd = gobj[dep];
|
576
589
|
if (!gd) {
|
577
|
-
gobj[dep] = gd = {};
|
590
|
+
gobj[dep] = gd = { _count: 0 };
|
591
|
+
}
|
592
|
+
if (gd._count === 0) {
|
578
593
|
node.addEventListener(dep, this.handleNative);
|
579
594
|
}
|
580
595
|
gd[name] = (gd[name] || 0) + 1;
|
596
|
+
gd._count = (gd._count || 0) + 1;
|
581
597
|
}
|
582
598
|
node.addEventListener(evType, handler);
|
583
599
|
if (recognizer.touchAction) {
|
@@ -595,9 +611,10 @@ dep = deps[i];
|
|
595
611
|
gd = gobj[dep];
|
596
612
|
if (gd && gd[name]) {
|
597
613
|
gd[name] = (gd[name] || 1) - 1;
|
598
|
-
|
599
|
-
node.removeEventListener(dep, this.handleNative);
|
614
|
+
gd._count = (gd._count || 1) - 1;
|
600
615
|
}
|
616
|
+
if (gd._count === 0) {
|
617
|
+
node.removeEventListener(dep, this.handleNative);
|
601
618
|
}
|
602
619
|
}
|
603
620
|
}
|
@@ -659,7 +676,7 @@ emits: [
|
|
659
676
|
'up'
|
660
677
|
],
|
661
678
|
mousedown: function (e) {
|
662
|
-
var t = e
|
679
|
+
var t = Gestures.findOriginalTarget(e);
|
663
680
|
var self = this;
|
664
681
|
var upfn = function upfn(e) {
|
665
682
|
self.fire('up', t, e);
|
@@ -669,10 +686,10 @@ document.addEventListener('mouseup', upfn);
|
|
669
686
|
this.fire('down', t, e);
|
670
687
|
},
|
671
688
|
touchstart: function (e) {
|
672
|
-
this.fire('down', e
|
689
|
+
this.fire('down', Gestures.findOriginalTarget(e), e.changedTouches[0]);
|
673
690
|
},
|
674
691
|
touchend: function (e) {
|
675
|
-
this.fire('up', e
|
692
|
+
this.fire('up', Gestures.findOriginalTarget(e), e.changedTouches[0]);
|
676
693
|
},
|
677
694
|
fire: function (type, target, event) {
|
678
695
|
var self = this;
|
@@ -728,7 +745,7 @@ var dy = Math.abs(this.info.y - y);
|
|
728
745
|
return dx >= TRACK_DISTANCE || dy >= TRACK_DISTANCE;
|
729
746
|
},
|
730
747
|
mousedown: function (e) {
|
731
|
-
var t = e
|
748
|
+
var t = Gestures.findOriginalTarget(e);
|
732
749
|
var self = this;
|
733
750
|
var movefn = function movefn(e) {
|
734
751
|
var x = e.clientX, y = e.clientY;
|
@@ -762,7 +779,7 @@ this.info.x = ct.clientX;
|
|
762
779
|
this.info.y = ct.clientY;
|
763
780
|
},
|
764
781
|
touchmove: function (e) {
|
765
|
-
var t = e
|
782
|
+
var t = Gestures.findOriginalTarget(e);
|
766
783
|
var ct = e.changedTouches[0];
|
767
784
|
var x = ct.clientX, y = ct.clientY;
|
768
785
|
if (this.hasMovedEnough(x, y)) {
|
@@ -776,7 +793,7 @@ this.info.started = true;
|
|
776
793
|
}
|
777
794
|
},
|
778
795
|
touchend: function (e) {
|
779
|
-
var t = e
|
796
|
+
var t = Gestures.findOriginalTarget(e);
|
780
797
|
var ct = e.changedTouches[0];
|
781
798
|
if (this.info.started) {
|
782
799
|
Gestures.prevent('tap');
|
@@ -852,9 +869,10 @@ this.forward(e.changedTouches[0]);
|
|
852
869
|
forward: function (e) {
|
853
870
|
var dx = Math.abs(e.clientX - this.info.x);
|
854
871
|
var dy = Math.abs(e.clientY - this.info.y);
|
872
|
+
var t = Gestures.findOriginalTarget(e);
|
855
873
|
if (isNaN(dx) || isNaN(dy) || dx <= TAP_DISTANCE && dy <= TAP_DISTANCE) {
|
856
874
|
if (!this.info.prevent) {
|
857
|
-
Gestures.fire(
|
875
|
+
Gestures.fire(t, 'tap', {
|
858
876
|
x: e.clientX,
|
859
877
|
y: e.clientY,
|
860
878
|
sourceEvent: e
|
@@ -1101,15 +1119,15 @@ Polymer.Bind = {
|
|
1101
1119
|
prepareModel: function (model) {
|
1102
1120
|
model._propertyEffects = {};
|
1103
1121
|
model._bindListeners = [];
|
1104
|
-
|
1105
|
-
for (var n in api) {
|
1106
|
-
model[n] = api[n];
|
1107
|
-
}
|
1122
|
+
Polymer.Base.mixin(model, this._modelApi);
|
1108
1123
|
},
|
1109
1124
|
_modelApi: {
|
1110
1125
|
_notifyChange: function (property) {
|
1111
1126
|
var eventName = Polymer.CaseMap.camelToDashCase(property) + '-changed';
|
1112
|
-
|
1127
|
+
Polymer.Base.fire(eventName, { value: this[property] }, {
|
1128
|
+
bubbles: false,
|
1129
|
+
node: this
|
1130
|
+
});
|
1113
1131
|
},
|
1114
1132
|
_propertySetter: function (property, value, effects, fromAbove) {
|
1115
1133
|
var old = this.__data__[property];
|
@@ -1200,8 +1218,11 @@ return this.__data__[property];
|
|
1200
1218
|
var setter = function (value) {
|
1201
1219
|
this._propertySetter(property, value, effects);
|
1202
1220
|
};
|
1203
|
-
|
1221
|
+
var info = model.getPropertyInfo && model.getPropertyInfo(property);
|
1222
|
+
if (info && info.readOnly) {
|
1223
|
+
if (!info.computed) {
|
1204
1224
|
model['_set' + this.upper(property)] = setter;
|
1225
|
+
}
|
1205
1226
|
} else {
|
1206
1227
|
defun.set = setter;
|
1207
1228
|
}
|
@@ -1659,6 +1680,7 @@ this._pathEffector(path, value);
|
|
1659
1680
|
if (!fromAbove) {
|
1660
1681
|
this._notifyPath(path, value);
|
1661
1682
|
}
|
1683
|
+
return true;
|
1662
1684
|
}
|
1663
1685
|
},
|
1664
1686
|
_getPathParts: function (path) {
|
@@ -2000,7 +2022,7 @@ var VAR_START = '--';
|
|
2000
2022
|
var MEDIA_START = '@media';
|
2001
2023
|
var AT_START = '@';
|
2002
2024
|
var rx = {
|
2003
|
-
comments: /\/\*[^*]*\*+([
|
2025
|
+
comments: /\/\*[^*]*\*+([^\/*][^*]*\*+)*\//gim,
|
2004
2026
|
port: /@import[^;]*;/gim,
|
2005
2027
|
customProp: /(?:^|[\s;])--[^;{]*?:[^{};]*?(?:[;\n]|$)/gim,
|
2006
2028
|
mixinProp: /(?:^|[\s;])--[^;{]*?:[^{;]*?{[^}]*?}(?:[;\n]|$)?/gim,
|
@@ -2672,10 +2694,10 @@ props[i] = v;
|
|
2672
2694
|
}
|
2673
2695
|
},
|
2674
2696
|
rx: {
|
2675
|
-
VAR_ASSIGN: /(?:^|[;\n]\s*)(--[\w-]*?):\s
|
2676
|
-
MIXIN_MATCH: /(?:^|\W+)@apply[\s]*\(([^)]*)\)/
|
2677
|
-
VAR_MATCH: /(^|\W+)var\([\s]*([^,)]*)[\s]*,?[\s]*((?:[^,)]*)|(?:[^;]*\([^;)]*\)))[\s]*?\)/
|
2678
|
-
VAR_CAPTURE: /\([\s]*(--[^,\s)]*)(?:,[\s]*(--[^,\s)]*))?(?:\)|,)/
|
2697
|
+
VAR_ASSIGN: /(?:^|[;\n]\s*)(--[\w-]*?):\s*(?:([^;{]*)|{([^}]*)})(?:(?=[;\n])|$)/gi,
|
2698
|
+
MIXIN_MATCH: /(?:^|\W+)@apply[\s]*\(([^)]*)\)/i,
|
2699
|
+
VAR_MATCH: /(^|\W+)var\([\s]*([^,)]*)[\s]*,?[\s]*((?:[^,)]*)|(?:[^;]*\([^;)]*\)))[\s]*?\)/gi,
|
2700
|
+
VAR_CAPTURE: /\([\s]*(--[^,\s)]*)(?:,[\s]*(--[^,\s)]*))?(?:\)|,)/gi,
|
2679
2701
|
IS_VAR: /^--/,
|
2680
2702
|
BRACKETED: /\{[^}]*\}/g,
|
2681
2703
|
HOST_PREFIX: '(?:^|[^.#[:])',
|
@@ -3014,7 +3036,7 @@ styleTransformer.documentRule(rule);
|
|
3014
3036
|
});
|
3015
3037
|
}());
|
3016
3038
|
Polymer.Templatizer = {
|
3017
|
-
properties: {
|
3039
|
+
properties: { __hideTemplateChildren__: { observer: '_showHideChildren' } },
|
3018
3040
|
_templatizerStatic: {
|
3019
3041
|
count: 0,
|
3020
3042
|
callbacks: {},
|
@@ -3043,6 +3065,7 @@ this._prepParentProperties(archetype, template);
|
|
3043
3065
|
archetype._notifyPath = this._notifyPathImpl;
|
3044
3066
|
archetype._scopeElementClass = this._scopeElementClassImpl;
|
3045
3067
|
archetype.listen = this._listenImpl;
|
3068
|
+
archetype._showHideChildren = this._showHideChildrenImpl;
|
3046
3069
|
var _constructor = this._constructorImpl;
|
3047
3070
|
var ctor = function TemplateInstance(model, host) {
|
3048
3071
|
_constructor.call(this, model, host);
|
@@ -3055,7 +3078,15 @@ this.ctor = ctor;
|
|
3055
3078
|
_getRootDataHost: function () {
|
3056
3079
|
return this.dataHost && this.dataHost._rootDataHost || this.dataHost;
|
3057
3080
|
},
|
3058
|
-
|
3081
|
+
_showHideChildrenImpl: function (hide) {
|
3082
|
+
var c = this._children;
|
3083
|
+
for (var i = 0; i < c.length; i++) {
|
3084
|
+
var n = c[i];
|
3085
|
+
if (n.style) {
|
3086
|
+
n.style.display = hide ? 'none' : '';
|
3087
|
+
n.__hideTemplateChildren__ = hide;
|
3088
|
+
}
|
3089
|
+
}
|
3059
3090
|
},
|
3060
3091
|
_debounceTemplate: function (fn) {
|
3061
3092
|
this._templatizerStatic.callbacks[this._templatizerId] = fn.bind(this);
|
@@ -3156,6 +3187,8 @@ template._propertySetter(n, val);
|
|
3156
3187
|
}
|
3157
3188
|
});
|
3158
3189
|
},
|
3190
|
+
_showHideChildren: function (hidden) {
|
3191
|
+
},
|
3159
3192
|
_forwardInstancePath: function (inst, path, value) {
|
3160
3193
|
},
|
3161
3194
|
_forwardInstanceProp: function (inst, prop, value) {
|
@@ -3194,6 +3227,9 @@ children.push(n);
|
|
3194
3227
|
n._templateInstance = this;
|
3195
3228
|
}
|
3196
3229
|
this._children = children;
|
3230
|
+
if (host.__hideTemplateChildren__) {
|
3231
|
+
this._showHideChildren(true);
|
3232
|
+
}
|
3197
3233
|
this._tryReady();
|
3198
3234
|
},
|
3199
3235
|
_listenImpl: function (node, eventName, methodName) {
|
@@ -3220,6 +3256,20 @@ model[prop] = this['_parent_' + prop];
|
|
3220
3256
|
}
|
3221
3257
|
}
|
3222
3258
|
return new this.ctor(model, this);
|
3259
|
+
},
|
3260
|
+
modelForElement: function (el) {
|
3261
|
+
var model;
|
3262
|
+
while (el) {
|
3263
|
+
if (model = el._templateInstance) {
|
3264
|
+
if (model.dataHost != this) {
|
3265
|
+
el = model.dataHost;
|
3266
|
+
} else {
|
3267
|
+
return model;
|
3268
|
+
}
|
3269
|
+
} else {
|
3270
|
+
el = el.parentNode;
|
3271
|
+
}
|
3272
|
+
}
|
3223
3273
|
}
|
3224
3274
|
};
|
3225
3275
|
Polymer({
|
@@ -3266,7 +3316,7 @@ this._removeFromMap(this.store[key]);
|
|
3266
3316
|
delete this.store[key];
|
3267
3317
|
},
|
3268
3318
|
_removeFromMap: function (item) {
|
3269
|
-
if (typeof item == 'object') {
|
3319
|
+
if (item && typeof item == 'object') {
|
3270
3320
|
this.omap.delete(item);
|
3271
3321
|
} else {
|
3272
3322
|
delete this.pmap[item];
|
@@ -3278,7 +3328,7 @@ this.removeKey(key);
|
|
3278
3328
|
return key;
|
3279
3329
|
},
|
3280
3330
|
getKey: function (item) {
|
3281
|
-
if (typeof item == 'object') {
|
3331
|
+
if (item && typeof item == 'object') {
|
3282
3332
|
return this.omap.get(item);
|
3283
3333
|
} else {
|
3284
3334
|
return this.pmap[item];
|
@@ -3647,14 +3697,7 @@ return row;
|
|
3647
3697
|
_showHideChildren: function (hidden) {
|
3648
3698
|
if (this.rows) {
|
3649
3699
|
for (var i = 0; i < this.rows.length; i++) {
|
3650
|
-
|
3651
|
-
for (var j = 0; j < c$.length; j++) {
|
3652
|
-
var c = c$[j];
|
3653
|
-
if (c.style) {
|
3654
|
-
c.style.display = hidden ? 'none' : '';
|
3655
|
-
}
|
3656
|
-
c._hideTemplateChildren = hidden;
|
3657
|
-
}
|
3700
|
+
this.rows[i]._showHideChildren(hidden);
|
3658
3701
|
}
|
3659
3702
|
}
|
3660
3703
|
},
|
@@ -3704,20 +3747,6 @@ row.__setProperty(this.as, value, true);
|
|
3704
3747
|
}
|
3705
3748
|
}
|
3706
3749
|
},
|
3707
|
-
modelForElement: function (el) {
|
3708
|
-
var model;
|
3709
|
-
while (el) {
|
3710
|
-
if (model = el._templateInstance) {
|
3711
|
-
if (model.dataHost != this) {
|
3712
|
-
el = model.dataHost;
|
3713
|
-
} else {
|
3714
|
-
return model;
|
3715
|
-
}
|
3716
|
-
} else {
|
3717
|
-
el = el.parentNode;
|
3718
|
-
}
|
3719
|
-
}
|
3720
|
-
},
|
3721
3750
|
itemForElement: function (el) {
|
3722
3751
|
var instance = this.modelForElement(el);
|
3723
3752
|
return instance && instance[this.as];
|
@@ -3872,7 +3901,7 @@ this._instance = null;
|
|
3872
3901
|
},
|
3873
3902
|
_wrapTextNodes: function (root) {
|
3874
3903
|
for (var n = root.firstChild; n; n = n.nextSibling) {
|
3875
|
-
if (n.nodeType === Node.TEXT_NODE) {
|
3904
|
+
if (n.nodeType === Node.TEXT_NODE && n.textContent.trim()) {
|
3876
3905
|
var s = document.createElement('span');
|
3877
3906
|
root.insertBefore(s, n);
|
3878
3907
|
s.appendChild(n);
|
@@ -3881,14 +3910,9 @@ n = s;
|
|
3881
3910
|
}
|
3882
3911
|
},
|
3883
3912
|
_showHideChildren: function () {
|
3884
|
-
var hidden = this.
|
3913
|
+
var hidden = this.__hideTemplateChildren__ || !this.if;
|
3885
3914
|
if (this._instance) {
|
3886
|
-
|
3887
|
-
for (var i = 0; i < c$.length; i++) {
|
3888
|
-
var c = c$[i];
|
3889
|
-
c.style.display = hidden ? 'none' : '';
|
3890
|
-
c._hideTemplateChildren = hidden;
|
3891
|
-
}
|
3915
|
+
this._instance._showHideChildren(hidden);
|
3892
3916
|
}
|
3893
3917
|
},
|
3894
3918
|
_forwardParentProp: function (prop, value) {
|
@@ -7,7 +7,7 @@
|
|
7
7
|
* Code distributed by Google as part of the polymer project is also
|
8
8
|
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
9
9
|
*/
|
10
|
-
// @version 0.7.
|
10
|
+
// @version 0.7.6
|
11
11
|
window.WebComponents = window.WebComponents || {};
|
12
12
|
|
13
13
|
(function(scope) {
|
@@ -1415,7 +1415,9 @@ window.HTMLImports.addModule(function(scope) {
|
|
1415
1415
|
script.src = scriptElt.src ? scriptElt.src : generateScriptDataUrl(scriptElt);
|
1416
1416
|
scope.currentScript = scriptElt;
|
1417
1417
|
this.trackElement(script, function(e) {
|
1418
|
-
script.parentNode
|
1418
|
+
if (script.parentNode) {
|
1419
|
+
script.parentNode.removeChild(script);
|
1420
|
+
}
|
1419
1421
|
scope.currentScript = null;
|
1420
1422
|
});
|
1421
1423
|
this.addElementToDocument(script);
|
@@ -1732,30 +1734,24 @@ window.CustomElements.addModule(function(scope) {
|
|
1732
1734
|
var flags = scope.flags;
|
1733
1735
|
var forSubtree = scope.forSubtree;
|
1734
1736
|
var forDocumentTree = scope.forDocumentTree;
|
1735
|
-
function addedNode(node) {
|
1736
|
-
return added(node) || addedSubtree(node);
|
1737
|
+
function addedNode(node, isAttached) {
|
1738
|
+
return added(node, isAttached) || addedSubtree(node, isAttached);
|
1737
1739
|
}
|
1738
|
-
function added(node) {
|
1739
|
-
if (scope.upgrade(node)) {
|
1740
|
+
function added(node, isAttached) {
|
1741
|
+
if (scope.upgrade(node, isAttached)) {
|
1740
1742
|
return true;
|
1741
1743
|
}
|
1742
|
-
|
1744
|
+
if (isAttached) {
|
1745
|
+
attached(node);
|
1746
|
+
}
|
1743
1747
|
}
|
1744
|
-
function addedSubtree(node) {
|
1748
|
+
function addedSubtree(node, isAttached) {
|
1745
1749
|
forSubtree(node, function(e) {
|
1746
|
-
if (added(e)) {
|
1750
|
+
if (added(e, isAttached)) {
|
1747
1751
|
return true;
|
1748
1752
|
}
|
1749
1753
|
});
|
1750
1754
|
}
|
1751
|
-
function attachedNode(node) {
|
1752
|
-
attached(node);
|
1753
|
-
if (inDocument(node)) {
|
1754
|
-
forSubtree(node, function(e) {
|
1755
|
-
attached(e);
|
1756
|
-
});
|
1757
|
-
}
|
1758
|
-
}
|
1759
1755
|
var hasPolyfillMutations = !window.MutationObserver || window.MutationObserver === window.JsMutationObserver;
|
1760
1756
|
scope.hasPolyfillMutations = hasPolyfillMutations;
|
1761
1757
|
var isPendingMutations = false;
|
@@ -1785,12 +1781,10 @@ window.CustomElements.addModule(function(scope) {
|
|
1785
1781
|
}
|
1786
1782
|
}
|
1787
1783
|
function _attached(element) {
|
1788
|
-
if (element.__upgraded__ &&
|
1789
|
-
|
1790
|
-
|
1791
|
-
|
1792
|
-
element.attachedCallback();
|
1793
|
-
}
|
1784
|
+
if (element.__upgraded__ && !element.__attached) {
|
1785
|
+
element.__attached = true;
|
1786
|
+
if (element.attachedCallback) {
|
1787
|
+
element.attachedCallback();
|
1794
1788
|
}
|
1795
1789
|
}
|
1796
1790
|
}
|
@@ -1810,18 +1804,16 @@ window.CustomElements.addModule(function(scope) {
|
|
1810
1804
|
}
|
1811
1805
|
}
|
1812
1806
|
function _detached(element) {
|
1813
|
-
if (element.__upgraded__ &&
|
1814
|
-
|
1815
|
-
|
1816
|
-
|
1817
|
-
element.detachedCallback();
|
1818
|
-
}
|
1807
|
+
if (element.__upgraded__ && element.__attached) {
|
1808
|
+
element.__attached = false;
|
1809
|
+
if (element.detachedCallback) {
|
1810
|
+
element.detachedCallback();
|
1819
1811
|
}
|
1820
1812
|
}
|
1821
1813
|
}
|
1822
1814
|
function inDocument(element) {
|
1823
1815
|
var p = element;
|
1824
|
-
var doc = wrap(document);
|
1816
|
+
var doc = window.wrap(document);
|
1825
1817
|
while (p) {
|
1826
1818
|
if (p == doc) {
|
1827
1819
|
return true;
|
@@ -1839,7 +1831,7 @@ window.CustomElements.addModule(function(scope) {
|
|
1839
1831
|
}
|
1840
1832
|
}
|
1841
1833
|
}
|
1842
|
-
function handler(mutations) {
|
1834
|
+
function handler(root, mutations) {
|
1843
1835
|
if (flags.dom) {
|
1844
1836
|
var mx = mutations[0];
|
1845
1837
|
if (mx && mx.type === "childList" && mx.addedNodes) {
|
@@ -1854,13 +1846,14 @@ window.CustomElements.addModule(function(scope) {
|
|
1854
1846
|
}
|
1855
1847
|
console.group("mutations (%d) [%s]", mutations.length, u || "");
|
1856
1848
|
}
|
1849
|
+
var isAttached = inDocument(root);
|
1857
1850
|
mutations.forEach(function(mx) {
|
1858
1851
|
if (mx.type === "childList") {
|
1859
1852
|
forEach(mx.addedNodes, function(n) {
|
1860
1853
|
if (!n.localName) {
|
1861
1854
|
return;
|
1862
1855
|
}
|
1863
|
-
addedNode(n);
|
1856
|
+
addedNode(n, isAttached);
|
1864
1857
|
});
|
1865
1858
|
forEach(mx.removedNodes, function(n) {
|
1866
1859
|
if (!n.localName) {
|
@@ -1882,7 +1875,7 @@ window.CustomElements.addModule(function(scope) {
|
|
1882
1875
|
}
|
1883
1876
|
var observer = node.__observer;
|
1884
1877
|
if (observer) {
|
1885
|
-
handler(observer.takeRecords());
|
1878
|
+
handler(node, observer.takeRecords());
|
1886
1879
|
takeMutations();
|
1887
1880
|
}
|
1888
1881
|
}
|
@@ -1891,7 +1884,7 @@ window.CustomElements.addModule(function(scope) {
|
|
1891
1884
|
if (inRoot.__observer) {
|
1892
1885
|
return;
|
1893
1886
|
}
|
1894
|
-
var observer = new MutationObserver(handler);
|
1887
|
+
var observer = new MutationObserver(handler.bind(this, inRoot));
|
1895
1888
|
observer.observe(inRoot, {
|
1896
1889
|
childList: true,
|
1897
1890
|
subtree: true
|
@@ -1901,7 +1894,8 @@ window.CustomElements.addModule(function(scope) {
|
|
1901
1894
|
function upgradeDocument(doc) {
|
1902
1895
|
doc = window.wrap(doc);
|
1903
1896
|
flags.dom && console.group("upgradeDocument: ", doc.baseURI.split("/").pop());
|
1904
|
-
|
1897
|
+
var isMainDocument = doc === window.wrap(document);
|
1898
|
+
addedNode(doc, isMainDocument);
|
1905
1899
|
observe(doc);
|
1906
1900
|
flags.dom && console.groupEnd();
|
1907
1901
|
}
|
@@ -1920,26 +1914,26 @@ window.CustomElements.addModule(function(scope) {
|
|
1920
1914
|
scope.upgradeDocumentTree = upgradeDocumentTree;
|
1921
1915
|
scope.upgradeSubtree = addedSubtree;
|
1922
1916
|
scope.upgradeAll = addedNode;
|
1923
|
-
scope.
|
1917
|
+
scope.attached = attached;
|
1924
1918
|
scope.takeRecords = takeRecords;
|
1925
1919
|
});
|
1926
1920
|
|
1927
1921
|
window.CustomElements.addModule(function(scope) {
|
1928
1922
|
var flags = scope.flags;
|
1929
|
-
function upgrade(node) {
|
1923
|
+
function upgrade(node, isAttached) {
|
1930
1924
|
if (!node.__upgraded__ && node.nodeType === Node.ELEMENT_NODE) {
|
1931
1925
|
var is = node.getAttribute("is");
|
1932
1926
|
var definition = scope.getRegisteredDefinition(is || node.localName);
|
1933
1927
|
if (definition) {
|
1934
1928
|
if (is && definition.tag == node.localName) {
|
1935
|
-
return upgradeWithDefinition(node, definition);
|
1929
|
+
return upgradeWithDefinition(node, definition, isAttached);
|
1936
1930
|
} else if (!is && !definition.extends) {
|
1937
|
-
return upgradeWithDefinition(node, definition);
|
1931
|
+
return upgradeWithDefinition(node, definition, isAttached);
|
1938
1932
|
}
|
1939
1933
|
}
|
1940
1934
|
}
|
1941
1935
|
}
|
1942
|
-
function upgradeWithDefinition(element, definition) {
|
1936
|
+
function upgradeWithDefinition(element, definition, isAttached) {
|
1943
1937
|
flags.upgrade && console.group("upgrade:", element.localName);
|
1944
1938
|
if (definition.is) {
|
1945
1939
|
element.setAttribute("is", definition.is);
|
@@ -1947,8 +1941,10 @@ window.CustomElements.addModule(function(scope) {
|
|
1947
1941
|
implementPrototype(element, definition);
|
1948
1942
|
element.__upgraded__ = true;
|
1949
1943
|
created(element);
|
1950
|
-
|
1951
|
-
|
1944
|
+
if (isAttached) {
|
1945
|
+
scope.attached(element);
|
1946
|
+
}
|
1947
|
+
scope.upgradeSubtree(element, isAttached);
|
1952
1948
|
flags.upgrade && console.groupEnd();
|
1953
1949
|
return element;
|
1954
1950
|
}
|
@@ -2230,7 +2226,7 @@ window.CustomElements.addModule(function(scope) {
|
|
2230
2226
|
upgradeDocumentTree(window.wrap(document));
|
2231
2227
|
if (window.HTMLImports) {
|
2232
2228
|
window.HTMLImports.__importsParsingHook = function(elt) {
|
2233
|
-
upgradeDocumentTree(wrap(elt.import));
|
2229
|
+
upgradeDocumentTree(window.wrap(elt.import));
|
2234
2230
|
};
|
2235
2231
|
}
|
2236
2232
|
window.CustomElements.ready = true;
|