polymer-gold-rails 1.0.0.pre.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +36 -0
- data/Rakefile +1 -0
- data/app/assets/components/gold-cc-cvc-input/README.md +24 -0
- data/app/assets/components/gold-cc-cvc-input/bower.json +39 -0
- data/app/assets/components/gold-cc-cvc-input/cvc_hint.png +0 -0
- data/app/assets/components/gold-cc-cvc-input/cvc_hint_amex.png +0 -0
- data/app/assets/components/gold-cc-cvc-input/demo/index.html +54 -0
- data/app/assets/components/gold-cc-cvc-input/gold-cc-cvc-input.html +195 -0
- data/app/assets/components/gold-cc-cvc-input/hero.svg +36 -0
- data/app/assets/components/gold-cc-cvc-input/index.html +26 -0
- data/app/assets/components/gold-cc-cvc-input/test/basic.html +125 -0
- data/app/assets/components/gold-cc-cvc-input/test/index.html +25 -0
- data/app/assets/components/gold-cc-expiration-input/README.md +10 -0
- data/app/assets/components/gold-cc-expiration-input/bower.json +40 -0
- data/app/assets/components/gold-cc-expiration-input/date-input.html +157 -0
- data/app/assets/components/gold-cc-expiration-input/date-validator.html +38 -0
- data/app/assets/components/gold-cc-expiration-input/demo/index.html +53 -0
- data/app/assets/components/gold-cc-expiration-input/gold-cc-expiration-input.html +131 -0
- data/app/assets/components/gold-cc-expiration-input/hero.svg +58 -0
- data/app/assets/components/gold-cc-expiration-input/index.html +28 -0
- data/app/assets/components/gold-cc-expiration-input/test/basic.html +126 -0
- data/app/assets/components/gold-cc-expiration-input/test/index.html +25 -0
- data/app/assets/components/gold-cc-input/README.md +9 -0
- data/app/assets/components/gold-cc-input/bower.json +39 -0
- data/app/assets/components/gold-cc-input/cc-validator.js +192 -0
- data/app/assets/components/gold-cc-input/demo/index.html +48 -0
- data/app/assets/components/gold-cc-input/gold-cc-input.html +215 -0
- data/app/assets/components/gold-cc-input/hero.svg +52 -0
- data/app/assets/components/gold-cc-input/images/amex.png +0 -0
- data/app/assets/components/gold-cc-input/images/diners_club.png +0 -0
- data/app/assets/components/gold-cc-input/images/discover.png +0 -0
- data/app/assets/components/gold-cc-input/images/jcb.png +0 -0
- data/app/assets/components/gold-cc-input/images/mastercard.png +0 -0
- data/app/assets/components/gold-cc-input/images/visa.png +0 -0
- data/app/assets/components/gold-cc-input/index.html +28 -0
- data/app/assets/components/gold-cc-input/test/basic.html +136 -0
- data/app/assets/components/gold-cc-input/test/index.html +25 -0
- data/app/assets/components/gold-elements/README.md +12 -0
- data/app/assets/components/gold-elements/bower.json +42 -0
- data/app/assets/components/gold-elements/demo/complex-form.html +127 -0
- data/app/assets/components/gold-elements/demo/index.html +94 -0
- data/app/assets/components/gold-elements/demo/item-card.html +59 -0
- data/app/assets/components/gold-elements/demo/simple-form.css +55 -0
- data/app/assets/components/gold-elements/demo/simple-form.html +93 -0
- data/app/assets/components/gold-elements/screenshot.png +0 -0
- data/app/assets/components/gold-email-input/README.md +8 -0
- data/app/assets/components/gold-email-input/bower.json +40 -0
- data/app/assets/components/gold-email-input/demo/index.html +46 -0
- data/app/assets/components/gold-email-input/email-validator.html +31 -0
- data/app/assets/components/gold-email-input/gold-email-input.html +108 -0
- data/app/assets/components/gold-email-input/hero.svg +59 -0
- data/app/assets/components/gold-email-input/index.html +28 -0
- data/app/assets/components/gold-email-input/test/basic.html +97 -0
- data/app/assets/components/gold-email-input/test/index.html +25 -0
- data/app/assets/components/gold-phone-input/README.md +13 -0
- data/app/assets/components/gold-phone-input/bower.json +39 -0
- data/app/assets/components/gold-phone-input/demo/index.html +53 -0
- data/app/assets/components/gold-phone-input/gold-phone-input.html +197 -0
- data/app/assets/components/gold-phone-input/hero.svg +63 -0
- data/app/assets/components/gold-phone-input/index.html +28 -0
- data/app/assets/components/gold-phone-input/test/basic.html +117 -0
- data/app/assets/components/gold-phone-input/test/index.html +25 -0
- data/app/assets/components/gold-zip-input/README.md +8 -0
- data/app/assets/components/gold-zip-input/bower.json +40 -0
- data/app/assets/components/gold-zip-input/demo/index.html +54 -0
- data/app/assets/components/gold-zip-input/gold-zip-input.html +113 -0
- data/app/assets/components/gold-zip-input/hero.svg +43 -0
- data/app/assets/components/gold-zip-input/index.html +28 -0
- data/app/assets/components/gold-zip-input/test/basic.html +116 -0
- data/app/assets/components/gold-zip-input/test/index.html +25 -0
- data/app/assets/components/gold-zip-input/zip-validator.html +32 -0
- data/app/assets/components/iron-autogrow-textarea/README.md +24 -0
- data/app/assets/components/iron-autogrow-textarea/bower.json +37 -0
- data/app/assets/components/iron-autogrow-textarea/demo/index.html +81 -0
- data/app/assets/components/iron-autogrow-textarea/hero.svg +33 -0
- data/app/assets/components/iron-autogrow-textarea/index.html +30 -0
- data/app/assets/components/iron-autogrow-textarea/iron-autogrow-textarea.html +263 -0
- data/app/assets/components/iron-autogrow-textarea/test/basic.html +94 -0
- data/app/assets/components/iron-autogrow-textarea/test/index.html +25 -0
- data/app/assets/components/iron-flex-layout/README.md +4 -0
- data/app/assets/components/iron-flex-layout/bower.json +21 -0
- data/app/assets/components/iron-flex-layout/classes/iron-flex-layout.html +307 -0
- data/app/assets/components/iron-flex-layout/classes/iron-shadow-flex-layout.html +302 -0
- data/app/assets/components/iron-flex-layout/demo/index.html +40 -0
- data/app/assets/components/iron-flex-layout/demo/x-app.html +106 -0
- data/app/assets/components/iron-flex-layout/iron-flex-layout.html +313 -0
- data/app/assets/components/iron-form-element-behavior/README.md +2 -0
- data/app/assets/components/iron-form-element-behavior/bower.json +27 -0
- data/app/assets/components/iron-form-element-behavior/demo/index.html +53 -0
- data/app/assets/components/iron-form-element-behavior/demo/simple-element.html +27 -0
- data/app/assets/components/iron-form-element-behavior/demo/simple-form.html +42 -0
- data/app/assets/components/iron-form-element-behavior/index.html +30 -0
- data/app/assets/components/iron-form-element-behavior/iron-form-element-behavior.html +50 -0
- data/app/assets/components/iron-icon/README.md +56 -0
- data/app/assets/components/iron-icon/bower.json +29 -0
- data/app/assets/components/iron-icon/demo/index.html +28 -0
- data/app/assets/components/iron-icon/demo/location.png +0 -0
- data/app/assets/components/iron-icon/hero.svg +19 -0
- data/app/assets/components/iron-icon/index.html +26 -0
- data/app/assets/components/iron-icon/iron-icon.html +187 -0
- data/app/assets/components/iron-icon/test/index.html +31 -0
- data/app/assets/components/iron-icon/test/iron-icon.html +120 -0
- data/app/assets/components/iron-input/README.md +16 -0
- data/app/assets/components/iron-input/bower.json +36 -0
- data/app/assets/components/iron-input/demo/index.html +87 -0
- data/app/assets/components/iron-input/hero.svg +19 -0
- data/app/assets/components/iron-input/index.html +30 -0
- data/app/assets/components/iron-input/iron-input.html +235 -0
- data/app/assets/components/iron-input/test/index.html +24 -0
- data/app/assets/components/iron-input/test/iron-input.html +139 -0
- data/app/assets/components/iron-input/test/letters-only.html +30 -0
- data/app/assets/components/iron-meta/README.md +46 -0
- data/app/assets/components/iron-meta/bower.json +28 -0
- data/app/assets/components/iron-meta/demo/index.html +45 -0
- data/app/assets/components/iron-meta/hero.svg +33 -0
- data/app/assets/components/iron-meta/index.html +27 -0
- data/app/assets/components/iron-meta/iron-meta.html +352 -0
- data/app/assets/components/iron-meta/test/basic.html +48 -0
- data/app/assets/components/iron-meta/test/index.html +30 -0
- data/app/assets/components/iron-meta/test/iron-meta.html +186 -0
- data/app/assets/components/iron-validatable-behavior/README.md +3 -0
- data/app/assets/components/iron-validatable-behavior/bower.json +35 -0
- data/app/assets/components/iron-validatable-behavior/demo/cats-only.html +46 -0
- data/app/assets/components/iron-validatable-behavior/demo/index.html +71 -0
- data/app/assets/components/iron-validatable-behavior/demo/validatable-input.html +46 -0
- data/app/assets/components/iron-validatable-behavior/index.html +30 -0
- data/app/assets/components/iron-validatable-behavior/iron-validatable-behavior.html +101 -0
- data/app/assets/components/iron-validatable-behavior/test/index.html +35 -0
- data/app/assets/components/iron-validatable-behavior/test/iron-validatable-behavior.html +52 -0
- data/app/assets/components/iron-validatable-behavior/test/test-validatable.html +28 -0
- data/app/assets/components/iron-validator-behavior/README.md +4 -0
- data/app/assets/components/iron-validator-behavior/bower.json +34 -0
- data/app/assets/components/iron-validator-behavior/demo/cats-only.html +46 -0
- data/app/assets/components/iron-validator-behavior/demo/index.html +144 -0
- data/app/assets/components/iron-validator-behavior/index.html +30 -0
- data/app/assets/components/iron-validator-behavior/iron-validator-behavior.html +61 -0
- data/app/assets/components/iron-validator-behavior/test/index.html +34 -0
- data/app/assets/components/iron-validator-behavior/test/iron-validator-behavior.html +47 -0
- data/app/assets/components/iron-validator-behavior/test/simple-validator.html +26 -0
- data/app/assets/components/paper-input/README.md +5 -0
- data/app/assets/components/paper-input/all-imports.html +12 -0
- data/app/assets/components/paper-input/bower.json +44 -0
- data/app/assets/components/paper-input/demo/index.html +96 -0
- data/app/assets/components/paper-input/demo/ssn-input.html +94 -0
- data/app/assets/components/paper-input/demo/ssn-validator.html +31 -0
- data/app/assets/components/paper-input/hero.svg +19 -0
- data/app/assets/components/paper-input/index.html +28 -0
- data/app/assets/components/paper-input/paper-input-addon-behavior.html +47 -0
- data/app/assets/components/paper-input/paper-input-behavior.html +317 -0
- data/app/assets/components/paper-input/paper-input-char-counter.html +95 -0
- data/app/assets/components/paper-input/paper-input-container.html +495 -0
- data/app/assets/components/paper-input/paper-input-error.html +99 -0
- data/app/assets/components/paper-input/paper-input.html +126 -0
- data/app/assets/components/paper-input/paper-textarea.html +106 -0
- data/app/assets/components/paper-input/test/index.html +28 -0
- data/app/assets/components/paper-input/test/letters-only.html +30 -0
- data/app/assets/components/paper-input/test/paper-input-char-counter.html +112 -0
- data/app/assets/components/paper-input/test/paper-input-container.html +237 -0
- data/app/assets/components/paper-input/test/paper-input-error.html +60 -0
- data/app/assets/components/paper-input/test/paper-input.html +213 -0
- data/app/assets/components/paper-input/test/paper-textarea.html +169 -0
- data/app/assets/components/paper-styles/README.md +3 -0
- data/app/assets/components/paper-styles/bower.json +27 -0
- data/app/assets/components/paper-styles/classes/global.html +96 -0
- data/app/assets/components/paper-styles/classes/shadow-layout.html +302 -0
- data/app/assets/components/paper-styles/classes/shadow.html +39 -0
- data/app/assets/components/paper-styles/classes/typography.html +171 -0
- data/app/assets/components/paper-styles/color.html +333 -0
- data/app/assets/components/paper-styles/default-theme.html +39 -0
- data/app/assets/components/paper-styles/demo-pages.html +72 -0
- data/app/assets/components/paper-styles/demo.css +25 -0
- data/app/assets/components/paper-styles/paper-styles-classes.html +14 -0
- data/app/assets/components/paper-styles/paper-styles.html +17 -0
- data/app/assets/components/paper-styles/shadow.html +61 -0
- data/app/assets/components/paper-styles/typography.html +240 -0
- data/app/assets/components/polymer/LICENSE.txt +27 -0
- data/app/assets/components/polymer/bower.json +26 -0
- data/app/assets/components/polymer/build.log +27 -0
- data/app/assets/components/polymer/polymer-micro.html +523 -0
- data/app/assets/components/polymer/polymer-mini.html +1368 -0
- data/app/assets/components/polymer/polymer.html +3768 -0
- data/app/assets/components/webcomponentsjs/CustomElements.js +956 -0
- data/app/assets/components/webcomponentsjs/CustomElements.min.js +11 -0
- data/app/assets/components/webcomponentsjs/HTMLImports.js +1078 -0
- data/app/assets/components/webcomponentsjs/HTMLImports.min.js +11 -0
- data/app/assets/components/webcomponentsjs/MutationObserver.js +344 -0
- data/app/assets/components/webcomponentsjs/MutationObserver.min.js +11 -0
- data/app/assets/components/webcomponentsjs/README.md +125 -0
- data/app/assets/components/webcomponentsjs/ShadowDOM.js +4414 -0
- data/app/assets/components/webcomponentsjs/ShadowDOM.min.js +15 -0
- data/app/assets/components/webcomponentsjs/bower.json +14 -0
- data/app/assets/components/webcomponentsjs/build.log +33 -0
- data/app/assets/components/webcomponentsjs/package.json +31 -0
- data/app/assets/components/webcomponentsjs/webcomponents-lite.js +2300 -0
- data/app/assets/components/webcomponentsjs/webcomponents-lite.min.js +13 -0
- data/app/assets/components/webcomponentsjs/webcomponents.js +7112 -0
- data/app/assets/components/webcomponentsjs/webcomponents.min.js +15 -0
- data/lib/polymer-gold-rails.rb +2 -0
- data/lib/polymer-gold-rails/enigne.rb +4 -0
- data/lib/polymer-gold-rails/version.rb +3 -0
- metadata +312 -0
@@ -0,0 +1,1368 @@
|
|
1
|
+
<!--
|
2
|
+
@license
|
3
|
+
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
4
|
+
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
5
|
+
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
6
|
+
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
7
|
+
Code distributed by Google as part of the polymer project is also
|
8
|
+
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
9
|
+
--><link rel="import" href="polymer-micro.html">
|
10
|
+
|
11
|
+
<script>Polymer.Base._addFeature({
|
12
|
+
_prepTemplate: function () {
|
13
|
+
this._template = this._template || Polymer.DomModule.import(this.is, 'template');
|
14
|
+
if (!this._template) {
|
15
|
+
var script = document._currentScript || document.currentScript;
|
16
|
+
var prev = script && script.previousElementSibling;
|
17
|
+
if (prev && prev.localName === 'template') {
|
18
|
+
this._template = prev;
|
19
|
+
}
|
20
|
+
}
|
21
|
+
if (this._template && this._template.hasAttribute('is')) {
|
22
|
+
this._warn(this._logf('_prepTemplate', 'top-level Polymer template ' + 'must not be a type-extension, found', this._template, 'Move inside simple <template>.'));
|
23
|
+
}
|
24
|
+
},
|
25
|
+
_stampTemplate: function () {
|
26
|
+
if (this._template) {
|
27
|
+
this.root = this.instanceTemplate(this._template);
|
28
|
+
}
|
29
|
+
},
|
30
|
+
instanceTemplate: function (template) {
|
31
|
+
var dom = document.importNode(template._content || template.content, true);
|
32
|
+
return dom;
|
33
|
+
}
|
34
|
+
});
|
35
|
+
(function () {
|
36
|
+
var baseAttachedCallback = Polymer.Base.attachedCallback;
|
37
|
+
Polymer.Base._addFeature({
|
38
|
+
_hostStack: [],
|
39
|
+
ready: function () {
|
40
|
+
},
|
41
|
+
_pushHost: function (host) {
|
42
|
+
this.dataHost = host = host || Polymer.Base._hostStack[Polymer.Base._hostStack.length - 1];
|
43
|
+
if (host && host._clients) {
|
44
|
+
host._clients.push(this);
|
45
|
+
}
|
46
|
+
this._beginHost();
|
47
|
+
},
|
48
|
+
_beginHost: function () {
|
49
|
+
Polymer.Base._hostStack.push(this);
|
50
|
+
if (!this._clients) {
|
51
|
+
this._clients = [];
|
52
|
+
}
|
53
|
+
},
|
54
|
+
_popHost: function () {
|
55
|
+
Polymer.Base._hostStack.pop();
|
56
|
+
},
|
57
|
+
_tryReady: function () {
|
58
|
+
if (this._canReady()) {
|
59
|
+
this._ready();
|
60
|
+
}
|
61
|
+
},
|
62
|
+
_canReady: function () {
|
63
|
+
return !this.dataHost || this.dataHost._clientsReadied;
|
64
|
+
},
|
65
|
+
_ready: function () {
|
66
|
+
this._beforeClientsReady();
|
67
|
+
this._setupRoot();
|
68
|
+
this._readyClients();
|
69
|
+
this._afterClientsReady();
|
70
|
+
this._readySelf();
|
71
|
+
},
|
72
|
+
_readyClients: function () {
|
73
|
+
this._beginDistribute();
|
74
|
+
var c$ = this._clients;
|
75
|
+
for (var i = 0, l = c$.length, c; i < l && (c = c$[i]); i++) {
|
76
|
+
c._ready();
|
77
|
+
}
|
78
|
+
this._finishDistribute();
|
79
|
+
this._clientsReadied = true;
|
80
|
+
this._clients = null;
|
81
|
+
},
|
82
|
+
_readySelf: function () {
|
83
|
+
this._doBehavior('ready');
|
84
|
+
this._readied = true;
|
85
|
+
if (this._attachedPending) {
|
86
|
+
this._attachedPending = false;
|
87
|
+
this.attachedCallback();
|
88
|
+
}
|
89
|
+
},
|
90
|
+
_beforeClientsReady: function () {
|
91
|
+
},
|
92
|
+
_afterClientsReady: function () {
|
93
|
+
},
|
94
|
+
_beforeAttached: function () {
|
95
|
+
},
|
96
|
+
attachedCallback: function () {
|
97
|
+
if (this._readied) {
|
98
|
+
this._beforeAttached();
|
99
|
+
baseAttachedCallback.call(this);
|
100
|
+
} else {
|
101
|
+
this._attachedPending = true;
|
102
|
+
}
|
103
|
+
}
|
104
|
+
});
|
105
|
+
}());
|
106
|
+
Polymer.ArraySplice = function () {
|
107
|
+
function newSplice(index, removed, addedCount) {
|
108
|
+
return {
|
109
|
+
index: index,
|
110
|
+
removed: removed,
|
111
|
+
addedCount: addedCount
|
112
|
+
};
|
113
|
+
}
|
114
|
+
var EDIT_LEAVE = 0;
|
115
|
+
var EDIT_UPDATE = 1;
|
116
|
+
var EDIT_ADD = 2;
|
117
|
+
var EDIT_DELETE = 3;
|
118
|
+
function ArraySplice() {
|
119
|
+
}
|
120
|
+
ArraySplice.prototype = {
|
121
|
+
calcEditDistances: function (current, currentStart, currentEnd, old, oldStart, oldEnd) {
|
122
|
+
var rowCount = oldEnd - oldStart + 1;
|
123
|
+
var columnCount = currentEnd - currentStart + 1;
|
124
|
+
var distances = new Array(rowCount);
|
125
|
+
for (var i = 0; i < rowCount; i++) {
|
126
|
+
distances[i] = new Array(columnCount);
|
127
|
+
distances[i][0] = i;
|
128
|
+
}
|
129
|
+
for (var j = 0; j < columnCount; j++)
|
130
|
+
distances[0][j] = j;
|
131
|
+
for (var i = 1; i < rowCount; i++) {
|
132
|
+
for (var j = 1; j < columnCount; j++) {
|
133
|
+
if (this.equals(current[currentStart + j - 1], old[oldStart + i - 1]))
|
134
|
+
distances[i][j] = distances[i - 1][j - 1];
|
135
|
+
else {
|
136
|
+
var north = distances[i - 1][j] + 1;
|
137
|
+
var west = distances[i][j - 1] + 1;
|
138
|
+
distances[i][j] = north < west ? north : west;
|
139
|
+
}
|
140
|
+
}
|
141
|
+
}
|
142
|
+
return distances;
|
143
|
+
},
|
144
|
+
spliceOperationsFromEditDistances: function (distances) {
|
145
|
+
var i = distances.length - 1;
|
146
|
+
var j = distances[0].length - 1;
|
147
|
+
var current = distances[i][j];
|
148
|
+
var edits = [];
|
149
|
+
while (i > 0 || j > 0) {
|
150
|
+
if (i == 0) {
|
151
|
+
edits.push(EDIT_ADD);
|
152
|
+
j--;
|
153
|
+
continue;
|
154
|
+
}
|
155
|
+
if (j == 0) {
|
156
|
+
edits.push(EDIT_DELETE);
|
157
|
+
i--;
|
158
|
+
continue;
|
159
|
+
}
|
160
|
+
var northWest = distances[i - 1][j - 1];
|
161
|
+
var west = distances[i - 1][j];
|
162
|
+
var north = distances[i][j - 1];
|
163
|
+
var min;
|
164
|
+
if (west < north)
|
165
|
+
min = west < northWest ? west : northWest;
|
166
|
+
else
|
167
|
+
min = north < northWest ? north : northWest;
|
168
|
+
if (min == northWest) {
|
169
|
+
if (northWest == current) {
|
170
|
+
edits.push(EDIT_LEAVE);
|
171
|
+
} else {
|
172
|
+
edits.push(EDIT_UPDATE);
|
173
|
+
current = northWest;
|
174
|
+
}
|
175
|
+
i--;
|
176
|
+
j--;
|
177
|
+
} else if (min == west) {
|
178
|
+
edits.push(EDIT_DELETE);
|
179
|
+
i--;
|
180
|
+
current = west;
|
181
|
+
} else {
|
182
|
+
edits.push(EDIT_ADD);
|
183
|
+
j--;
|
184
|
+
current = north;
|
185
|
+
}
|
186
|
+
}
|
187
|
+
edits.reverse();
|
188
|
+
return edits;
|
189
|
+
},
|
190
|
+
calcSplices: function (current, currentStart, currentEnd, old, oldStart, oldEnd) {
|
191
|
+
var prefixCount = 0;
|
192
|
+
var suffixCount = 0;
|
193
|
+
var minLength = Math.min(currentEnd - currentStart, oldEnd - oldStart);
|
194
|
+
if (currentStart == 0 && oldStart == 0)
|
195
|
+
prefixCount = this.sharedPrefix(current, old, minLength);
|
196
|
+
if (currentEnd == current.length && oldEnd == old.length)
|
197
|
+
suffixCount = this.sharedSuffix(current, old, minLength - prefixCount);
|
198
|
+
currentStart += prefixCount;
|
199
|
+
oldStart += prefixCount;
|
200
|
+
currentEnd -= suffixCount;
|
201
|
+
oldEnd -= suffixCount;
|
202
|
+
if (currentEnd - currentStart == 0 && oldEnd - oldStart == 0)
|
203
|
+
return [];
|
204
|
+
if (currentStart == currentEnd) {
|
205
|
+
var splice = newSplice(currentStart, [], 0);
|
206
|
+
while (oldStart < oldEnd)
|
207
|
+
splice.removed.push(old[oldStart++]);
|
208
|
+
return [splice];
|
209
|
+
} else if (oldStart == oldEnd)
|
210
|
+
return [newSplice(currentStart, [], currentEnd - currentStart)];
|
211
|
+
var ops = this.spliceOperationsFromEditDistances(this.calcEditDistances(current, currentStart, currentEnd, old, oldStart, oldEnd));
|
212
|
+
var splice = undefined;
|
213
|
+
var splices = [];
|
214
|
+
var index = currentStart;
|
215
|
+
var oldIndex = oldStart;
|
216
|
+
for (var i = 0; i < ops.length; i++) {
|
217
|
+
switch (ops[i]) {
|
218
|
+
case EDIT_LEAVE:
|
219
|
+
if (splice) {
|
220
|
+
splices.push(splice);
|
221
|
+
splice = undefined;
|
222
|
+
}
|
223
|
+
index++;
|
224
|
+
oldIndex++;
|
225
|
+
break;
|
226
|
+
case EDIT_UPDATE:
|
227
|
+
if (!splice)
|
228
|
+
splice = newSplice(index, [], 0);
|
229
|
+
splice.addedCount++;
|
230
|
+
index++;
|
231
|
+
splice.removed.push(old[oldIndex]);
|
232
|
+
oldIndex++;
|
233
|
+
break;
|
234
|
+
case EDIT_ADD:
|
235
|
+
if (!splice)
|
236
|
+
splice = newSplice(index, [], 0);
|
237
|
+
splice.addedCount++;
|
238
|
+
index++;
|
239
|
+
break;
|
240
|
+
case EDIT_DELETE:
|
241
|
+
if (!splice)
|
242
|
+
splice = newSplice(index, [], 0);
|
243
|
+
splice.removed.push(old[oldIndex]);
|
244
|
+
oldIndex++;
|
245
|
+
break;
|
246
|
+
}
|
247
|
+
}
|
248
|
+
if (splice) {
|
249
|
+
splices.push(splice);
|
250
|
+
}
|
251
|
+
return splices;
|
252
|
+
},
|
253
|
+
sharedPrefix: function (current, old, searchLength) {
|
254
|
+
for (var i = 0; i < searchLength; i++)
|
255
|
+
if (!this.equals(current[i], old[i]))
|
256
|
+
return i;
|
257
|
+
return searchLength;
|
258
|
+
},
|
259
|
+
sharedSuffix: function (current, old, searchLength) {
|
260
|
+
var index1 = current.length;
|
261
|
+
var index2 = old.length;
|
262
|
+
var count = 0;
|
263
|
+
while (count < searchLength && this.equals(current[--index1], old[--index2]))
|
264
|
+
count++;
|
265
|
+
return count;
|
266
|
+
},
|
267
|
+
calculateSplices: function (current, previous) {
|
268
|
+
return this.calcSplices(current, 0, current.length, previous, 0, previous.length);
|
269
|
+
},
|
270
|
+
equals: function (currentValue, previousValue) {
|
271
|
+
return currentValue === previousValue;
|
272
|
+
}
|
273
|
+
};
|
274
|
+
return new ArraySplice();
|
275
|
+
}();
|
276
|
+
Polymer.EventApi = function () {
|
277
|
+
var Settings = Polymer.Settings;
|
278
|
+
var EventApi = function (event) {
|
279
|
+
this.event = event;
|
280
|
+
};
|
281
|
+
if (Settings.useShadow) {
|
282
|
+
EventApi.prototype = {
|
283
|
+
get rootTarget() {
|
284
|
+
return this.event.path[0];
|
285
|
+
},
|
286
|
+
get localTarget() {
|
287
|
+
return this.event.target;
|
288
|
+
},
|
289
|
+
get path() {
|
290
|
+
return this.event.path;
|
291
|
+
}
|
292
|
+
};
|
293
|
+
} else {
|
294
|
+
EventApi.prototype = {
|
295
|
+
get rootTarget() {
|
296
|
+
return this.event.target;
|
297
|
+
},
|
298
|
+
get localTarget() {
|
299
|
+
var current = this.event.currentTarget;
|
300
|
+
var currentRoot = current && Polymer.dom(current).getOwnerRoot();
|
301
|
+
var p$ = this.path;
|
302
|
+
for (var i = 0; i < p$.length; i++) {
|
303
|
+
if (Polymer.dom(p$[i]).getOwnerRoot() === currentRoot) {
|
304
|
+
return p$[i];
|
305
|
+
}
|
306
|
+
}
|
307
|
+
},
|
308
|
+
get path() {
|
309
|
+
if (!this.event._path) {
|
310
|
+
var path = [];
|
311
|
+
var o = this.rootTarget;
|
312
|
+
while (o) {
|
313
|
+
path.push(o);
|
314
|
+
o = Polymer.dom(o).parentNode || o.host;
|
315
|
+
}
|
316
|
+
path.push(window);
|
317
|
+
this.event._path = path;
|
318
|
+
}
|
319
|
+
return this.event._path;
|
320
|
+
}
|
321
|
+
};
|
322
|
+
}
|
323
|
+
var factory = function (event) {
|
324
|
+
if (!event.__eventApi) {
|
325
|
+
event.__eventApi = new EventApi(event);
|
326
|
+
}
|
327
|
+
return event.__eventApi;
|
328
|
+
};
|
329
|
+
return { factory: factory };
|
330
|
+
}();
|
331
|
+
Polymer.domInnerHTML = function () {
|
332
|
+
var escapeAttrRegExp = /[&\u00A0"]/g;
|
333
|
+
var escapeDataRegExp = /[&\u00A0<>]/g;
|
334
|
+
function escapeReplace(c) {
|
335
|
+
switch (c) {
|
336
|
+
case '&':
|
337
|
+
return '&';
|
338
|
+
case '<':
|
339
|
+
return '<';
|
340
|
+
case '>':
|
341
|
+
return '>';
|
342
|
+
case '"':
|
343
|
+
return '"';
|
344
|
+
case '\xA0':
|
345
|
+
return ' ';
|
346
|
+
}
|
347
|
+
}
|
348
|
+
function escapeAttr(s) {
|
349
|
+
return s.replace(escapeAttrRegExp, escapeReplace);
|
350
|
+
}
|
351
|
+
function escapeData(s) {
|
352
|
+
return s.replace(escapeDataRegExp, escapeReplace);
|
353
|
+
}
|
354
|
+
function makeSet(arr) {
|
355
|
+
var set = {};
|
356
|
+
for (var i = 0; i < arr.length; i++) {
|
357
|
+
set[arr[i]] = true;
|
358
|
+
}
|
359
|
+
return set;
|
360
|
+
}
|
361
|
+
var voidElements = makeSet([
|
362
|
+
'area',
|
363
|
+
'base',
|
364
|
+
'br',
|
365
|
+
'col',
|
366
|
+
'command',
|
367
|
+
'embed',
|
368
|
+
'hr',
|
369
|
+
'img',
|
370
|
+
'input',
|
371
|
+
'keygen',
|
372
|
+
'link',
|
373
|
+
'meta',
|
374
|
+
'param',
|
375
|
+
'source',
|
376
|
+
'track',
|
377
|
+
'wbr'
|
378
|
+
]);
|
379
|
+
var plaintextParents = makeSet([
|
380
|
+
'style',
|
381
|
+
'script',
|
382
|
+
'xmp',
|
383
|
+
'iframe',
|
384
|
+
'noembed',
|
385
|
+
'noframes',
|
386
|
+
'plaintext',
|
387
|
+
'noscript'
|
388
|
+
]);
|
389
|
+
function getOuterHTML(node, parentNode, composed) {
|
390
|
+
switch (node.nodeType) {
|
391
|
+
case Node.ELEMENT_NODE:
|
392
|
+
var tagName = node.localName;
|
393
|
+
var s = '<' + tagName;
|
394
|
+
var attrs = node.attributes;
|
395
|
+
for (var i = 0, attr; attr = attrs[i]; i++) {
|
396
|
+
s += ' ' + attr.name + '="' + escapeAttr(attr.value) + '"';
|
397
|
+
}
|
398
|
+
s += '>';
|
399
|
+
if (voidElements[tagName]) {
|
400
|
+
return s;
|
401
|
+
}
|
402
|
+
return s + getInnerHTML(node, composed) + '</' + tagName + '>';
|
403
|
+
case Node.TEXT_NODE:
|
404
|
+
var data = node.data;
|
405
|
+
if (parentNode && plaintextParents[parentNode.localName]) {
|
406
|
+
return data;
|
407
|
+
}
|
408
|
+
return escapeData(data);
|
409
|
+
case Node.COMMENT_NODE:
|
410
|
+
return '<!--' + node.data + '-->';
|
411
|
+
default:
|
412
|
+
console.error(node);
|
413
|
+
throw new Error('not implemented');
|
414
|
+
}
|
415
|
+
}
|
416
|
+
function getInnerHTML(node, composed) {
|
417
|
+
if (node instanceof HTMLTemplateElement)
|
418
|
+
node = node.content;
|
419
|
+
var s = '';
|
420
|
+
var c$ = Polymer.dom(node).childNodes;
|
421
|
+
c$ = composed ? node._composedChildren : c$;
|
422
|
+
for (var i = 0, l = c$.length, child; i < l && (child = c$[i]); i++) {
|
423
|
+
s += getOuterHTML(child, node, composed);
|
424
|
+
}
|
425
|
+
return s;
|
426
|
+
}
|
427
|
+
return { getInnerHTML: getInnerHTML };
|
428
|
+
}();
|
429
|
+
Polymer.DomApi = function () {
|
430
|
+
'use strict';
|
431
|
+
var Settings = Polymer.Settings;
|
432
|
+
var getInnerHTML = Polymer.domInnerHTML.getInnerHTML;
|
433
|
+
var nativeInsertBefore = Element.prototype.insertBefore;
|
434
|
+
var nativeRemoveChild = Element.prototype.removeChild;
|
435
|
+
var nativeAppendChild = Element.prototype.appendChild;
|
436
|
+
var dirtyRoots = [];
|
437
|
+
var DomApi = function (node) {
|
438
|
+
this.node = node;
|
439
|
+
if (this.patch) {
|
440
|
+
this.patch();
|
441
|
+
}
|
442
|
+
};
|
443
|
+
DomApi.prototype = {
|
444
|
+
flush: function () {
|
445
|
+
for (var i = 0, host; i < dirtyRoots.length; i++) {
|
446
|
+
host = dirtyRoots[i];
|
447
|
+
host.flushDebouncer('_distribute');
|
448
|
+
}
|
449
|
+
dirtyRoots = [];
|
450
|
+
},
|
451
|
+
_lazyDistribute: function (host) {
|
452
|
+
if (host.shadyRoot && host.shadyRoot._distributionClean) {
|
453
|
+
host.shadyRoot._distributionClean = false;
|
454
|
+
host.debounce('_distribute', host._distributeContent);
|
455
|
+
dirtyRoots.push(host);
|
456
|
+
}
|
457
|
+
},
|
458
|
+
appendChild: function (node) {
|
459
|
+
var distributed;
|
460
|
+
this._removeNodeFromHost(node);
|
461
|
+
if (this._nodeIsInLogicalTree(this.node)) {
|
462
|
+
var host = this._hostForNode(this.node);
|
463
|
+
this._addLogicalInfo(node, this.node, host && host.shadyRoot);
|
464
|
+
this._addNodeToHost(node);
|
465
|
+
if (host) {
|
466
|
+
distributed = this._maybeDistribute(node, this.node, host);
|
467
|
+
}
|
468
|
+
}
|
469
|
+
if (!distributed && !this._tryRemoveUndistributedNode(node)) {
|
470
|
+
var container = this.node._isShadyRoot ? this.node.host : this.node;
|
471
|
+
nativeAppendChild.call(container, node);
|
472
|
+
addToComposedParent(container, node);
|
473
|
+
}
|
474
|
+
return node;
|
475
|
+
},
|
476
|
+
insertBefore: function (node, ref_node) {
|
477
|
+
if (!ref_node) {
|
478
|
+
return this.appendChild(node);
|
479
|
+
}
|
480
|
+
var distributed;
|
481
|
+
this._removeNodeFromHost(node);
|
482
|
+
if (this._nodeIsInLogicalTree(this.node)) {
|
483
|
+
saveLightChildrenIfNeeded(this.node);
|
484
|
+
var children = this.childNodes;
|
485
|
+
var index = children.indexOf(ref_node);
|
486
|
+
if (index < 0) {
|
487
|
+
throw Error('The ref_node to be inserted before is not a child ' + 'of this node');
|
488
|
+
}
|
489
|
+
var host = this._hostForNode(this.node);
|
490
|
+
this._addLogicalInfo(node, this.node, host && host.shadyRoot, index);
|
491
|
+
this._addNodeToHost(node);
|
492
|
+
if (host) {
|
493
|
+
distributed = this._maybeDistribute(node, this.node, host);
|
494
|
+
}
|
495
|
+
}
|
496
|
+
if (!distributed && !this._tryRemoveUndistributedNode(node)) {
|
497
|
+
ref_node = ref_node.localName === CONTENT ? this._firstComposedNode(ref_node) : ref_node;
|
498
|
+
var container = this.node._isShadyRoot ? this.node.host : this.node;
|
499
|
+
nativeInsertBefore.call(container, node, ref_node);
|
500
|
+
addToComposedParent(container, node, ref_node);
|
501
|
+
}
|
502
|
+
return node;
|
503
|
+
},
|
504
|
+
removeChild: function (node) {
|
505
|
+
if (factory(node).parentNode !== this.node) {
|
506
|
+
console.warn('The node to be removed is not a child of this node', node);
|
507
|
+
}
|
508
|
+
var distributed;
|
509
|
+
if (this._nodeIsInLogicalTree(this.node)) {
|
510
|
+
var host = this._hostForNode(this.node);
|
511
|
+
distributed = this._maybeDistribute(node, this.node, host);
|
512
|
+
this._removeNodeFromHost(node);
|
513
|
+
}
|
514
|
+
if (!distributed) {
|
515
|
+
var container = this.node._isShadyRoot ? this.node.host : this.node;
|
516
|
+
if (container === node.parentNode) {
|
517
|
+
nativeRemoveChild.call(container, node);
|
518
|
+
removeFromComposedParent(container, node);
|
519
|
+
}
|
520
|
+
}
|
521
|
+
return node;
|
522
|
+
},
|
523
|
+
replaceChild: function (node, ref_node) {
|
524
|
+
this.insertBefore(node, ref_node);
|
525
|
+
this.removeChild(ref_node);
|
526
|
+
return node;
|
527
|
+
},
|
528
|
+
getOwnerRoot: function () {
|
529
|
+
return this._ownerShadyRootForNode(this.node);
|
530
|
+
},
|
531
|
+
_ownerShadyRootForNode: function (node) {
|
532
|
+
if (!node) {
|
533
|
+
return;
|
534
|
+
}
|
535
|
+
if (node._ownerShadyRoot === undefined) {
|
536
|
+
var root;
|
537
|
+
if (node._isShadyRoot) {
|
538
|
+
root = node;
|
539
|
+
} else {
|
540
|
+
var parent = Polymer.dom(node).parentNode;
|
541
|
+
if (parent) {
|
542
|
+
root = parent._isShadyRoot ? parent : this._ownerShadyRootForNode(parent);
|
543
|
+
} else {
|
544
|
+
root = null;
|
545
|
+
}
|
546
|
+
}
|
547
|
+
node._ownerShadyRoot = root;
|
548
|
+
}
|
549
|
+
return node._ownerShadyRoot;
|
550
|
+
},
|
551
|
+
_maybeDistribute: function (node, parent, host) {
|
552
|
+
var nodeNeedsDistribute = this._nodeNeedsDistribution(node);
|
553
|
+
var distribute = this._parentNeedsDistribution(parent) || nodeNeedsDistribute;
|
554
|
+
if (nodeNeedsDistribute) {
|
555
|
+
this._updateInsertionPoints(host);
|
556
|
+
}
|
557
|
+
if (distribute) {
|
558
|
+
this._lazyDistribute(host);
|
559
|
+
}
|
560
|
+
return distribute;
|
561
|
+
},
|
562
|
+
_tryRemoveUndistributedNode: function (node) {
|
563
|
+
if (this.node.shadyRoot) {
|
564
|
+
if (node.parentNode) {
|
565
|
+
nativeRemoveChild.call(node.parentNode, node);
|
566
|
+
}
|
567
|
+
return true;
|
568
|
+
}
|
569
|
+
},
|
570
|
+
_updateInsertionPoints: function (host) {
|
571
|
+
host.shadyRoot._insertionPoints = factory(host.shadyRoot).querySelectorAll(CONTENT);
|
572
|
+
},
|
573
|
+
_nodeIsInLogicalTree: function (node) {
|
574
|
+
return Boolean(node._lightParent || node._isShadyRoot || this._ownerShadyRootForNode(node) || node.shadyRoot);
|
575
|
+
},
|
576
|
+
_hostForNode: function (node) {
|
577
|
+
var root = node.shadyRoot || (node._isShadyRoot ? node : this._ownerShadyRootForNode(node));
|
578
|
+
return root && root.host;
|
579
|
+
},
|
580
|
+
_parentNeedsDistribution: function (parent) {
|
581
|
+
return parent && parent.shadyRoot && hasInsertionPoint(parent.shadyRoot);
|
582
|
+
},
|
583
|
+
_nodeNeedsDistribution: function (node) {
|
584
|
+
return node.localName === CONTENT || node.nodeType === Node.DOCUMENT_FRAGMENT_NODE && node.querySelector(CONTENT);
|
585
|
+
},
|
586
|
+
_removeNodeFromHost: function (node) {
|
587
|
+
if (node._lightParent) {
|
588
|
+
var root = this._ownerShadyRootForNode(node);
|
589
|
+
if (root) {
|
590
|
+
root.host._elementRemove(node);
|
591
|
+
}
|
592
|
+
this._removeLogicalInfo(node, node._lightParent);
|
593
|
+
}
|
594
|
+
this._removeOwnerShadyRoot(node);
|
595
|
+
},
|
596
|
+
_addNodeToHost: function (node) {
|
597
|
+
var checkNode = node.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? node.firstChild : node;
|
598
|
+
var root = this._ownerShadyRootForNode(checkNode);
|
599
|
+
if (root) {
|
600
|
+
root.host._elementAdd(node);
|
601
|
+
}
|
602
|
+
},
|
603
|
+
_addLogicalInfo: function (node, container, root, index) {
|
604
|
+
saveLightChildrenIfNeeded(container);
|
605
|
+
var children = factory(container).childNodes;
|
606
|
+
index = index === undefined ? children.length : index;
|
607
|
+
if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
|
608
|
+
var c$ = Array.prototype.slice.call(node.childNodes);
|
609
|
+
for (var i = 0, n; i < c$.length && (n = c$[i]); i++) {
|
610
|
+
children.splice(index++, 0, n);
|
611
|
+
n._lightParent = container;
|
612
|
+
}
|
613
|
+
} else {
|
614
|
+
children.splice(index, 0, node);
|
615
|
+
node._lightParent = container;
|
616
|
+
}
|
617
|
+
},
|
618
|
+
_removeLogicalInfo: function (node, container) {
|
619
|
+
var children = factory(container).childNodes;
|
620
|
+
var index = children.indexOf(node);
|
621
|
+
if (index < 0 || container !== node._lightParent) {
|
622
|
+
throw Error('The node to be removed is not a child of this node');
|
623
|
+
}
|
624
|
+
children.splice(index, 1);
|
625
|
+
node._lightParent = null;
|
626
|
+
},
|
627
|
+
_removeOwnerShadyRoot: function (node) {
|
628
|
+
var hasCachedRoot = factory(node).getOwnerRoot() !== undefined;
|
629
|
+
if (hasCachedRoot) {
|
630
|
+
var c$ = factory(node).childNodes;
|
631
|
+
for (var i = 0, l = c$.length, n; i < l && (n = c$[i]); i++) {
|
632
|
+
this._removeOwnerShadyRoot(n);
|
633
|
+
}
|
634
|
+
}
|
635
|
+
node._ownerShadyRoot = undefined;
|
636
|
+
},
|
637
|
+
_firstComposedNode: function (content) {
|
638
|
+
var n$ = factory(content).getDistributedNodes();
|
639
|
+
for (var i = 0, l = n$.length, n, p$; i < l && (n = n$[i]); i++) {
|
640
|
+
p$ = factory(n).getDestinationInsertionPoints();
|
641
|
+
if (p$[p$.length - 1] === content) {
|
642
|
+
return n;
|
643
|
+
}
|
644
|
+
}
|
645
|
+
},
|
646
|
+
querySelector: function (selector) {
|
647
|
+
return this.querySelectorAll(selector)[0];
|
648
|
+
},
|
649
|
+
querySelectorAll: function (selector) {
|
650
|
+
return this._query(function (n) {
|
651
|
+
return matchesSelector.call(n, selector);
|
652
|
+
}, this.node);
|
653
|
+
},
|
654
|
+
_query: function (matcher, node) {
|
655
|
+
node = node || this.node;
|
656
|
+
var list = [];
|
657
|
+
this._queryElements(factory(node).childNodes, matcher, list);
|
658
|
+
return list;
|
659
|
+
},
|
660
|
+
_queryElements: function (elements, matcher, list) {
|
661
|
+
for (var i = 0, l = elements.length, c; i < l && (c = elements[i]); i++) {
|
662
|
+
if (c.nodeType === Node.ELEMENT_NODE) {
|
663
|
+
this._queryElement(c, matcher, list);
|
664
|
+
}
|
665
|
+
}
|
666
|
+
},
|
667
|
+
_queryElement: function (node, matcher, list) {
|
668
|
+
if (matcher(node)) {
|
669
|
+
list.push(node);
|
670
|
+
}
|
671
|
+
this._queryElements(factory(node).childNodes, matcher, list);
|
672
|
+
},
|
673
|
+
getDestinationInsertionPoints: function () {
|
674
|
+
return this.node._destinationInsertionPoints || [];
|
675
|
+
},
|
676
|
+
getDistributedNodes: function () {
|
677
|
+
return this.node._distributedNodes || [];
|
678
|
+
},
|
679
|
+
queryDistributedElements: function (selector) {
|
680
|
+
var c$ = this.childNodes;
|
681
|
+
var list = [];
|
682
|
+
this._distributedFilter(selector, c$, list);
|
683
|
+
for (var i = 0, l = c$.length, c; i < l && (c = c$[i]); i++) {
|
684
|
+
if (c.localName === CONTENT) {
|
685
|
+
this._distributedFilter(selector, factory(c).getDistributedNodes(), list);
|
686
|
+
}
|
687
|
+
}
|
688
|
+
return list;
|
689
|
+
},
|
690
|
+
_distributedFilter: function (selector, list, results) {
|
691
|
+
results = results || [];
|
692
|
+
for (var i = 0, l = list.length, d; i < l && (d = list[i]); i++) {
|
693
|
+
if (d.nodeType === Node.ELEMENT_NODE && d.localName !== CONTENT && matchesSelector.call(d, selector)) {
|
694
|
+
results.push(d);
|
695
|
+
}
|
696
|
+
}
|
697
|
+
return results;
|
698
|
+
},
|
699
|
+
_clear: function () {
|
700
|
+
while (this.childNodes.length) {
|
701
|
+
this.removeChild(this.childNodes[0]);
|
702
|
+
}
|
703
|
+
},
|
704
|
+
setAttribute: function (name, value) {
|
705
|
+
this.node.setAttribute(name, value);
|
706
|
+
this._distributeParent();
|
707
|
+
},
|
708
|
+
removeAttribute: function (name) {
|
709
|
+
this.node.removeAttribute(name);
|
710
|
+
this._distributeParent();
|
711
|
+
},
|
712
|
+
_distributeParent: function () {
|
713
|
+
if (this._parentNeedsDistribution(this.parentNode)) {
|
714
|
+
this._lazyDistribute(this.parentNode);
|
715
|
+
}
|
716
|
+
}
|
717
|
+
};
|
718
|
+
Object.defineProperty(DomApi.prototype, 'classList', {
|
719
|
+
get: function () {
|
720
|
+
if (!this._classList) {
|
721
|
+
this._classList = new DomApi.ClassList(this);
|
722
|
+
}
|
723
|
+
return this._classList;
|
724
|
+
},
|
725
|
+
configurable: true
|
726
|
+
});
|
727
|
+
DomApi.ClassList = function (host) {
|
728
|
+
this.domApi = host;
|
729
|
+
this.node = host.node;
|
730
|
+
};
|
731
|
+
DomApi.ClassList.prototype = {
|
732
|
+
add: function () {
|
733
|
+
this.node.classList.add.apply(this.node.classList, arguments);
|
734
|
+
this.domApi._distributeParent();
|
735
|
+
},
|
736
|
+
remove: function () {
|
737
|
+
this.node.classList.remove.apply(this.node.classList, arguments);
|
738
|
+
this.domApi._distributeParent();
|
739
|
+
},
|
740
|
+
toggle: function () {
|
741
|
+
this.node.classList.toggle.apply(this.node.classList, arguments);
|
742
|
+
this.domApi._distributeParent();
|
743
|
+
}
|
744
|
+
};
|
745
|
+
if (!Settings.useShadow) {
|
746
|
+
Object.defineProperties(DomApi.prototype, {
|
747
|
+
childNodes: {
|
748
|
+
get: function () {
|
749
|
+
var c$ = getLightChildren(this.node);
|
750
|
+
return Array.isArray(c$) ? c$ : Array.prototype.slice.call(c$);
|
751
|
+
},
|
752
|
+
configurable: true
|
753
|
+
},
|
754
|
+
children: {
|
755
|
+
get: function () {
|
756
|
+
return Array.prototype.filter.call(this.childNodes, function (n) {
|
757
|
+
return n.nodeType === Node.ELEMENT_NODE;
|
758
|
+
});
|
759
|
+
},
|
760
|
+
configurable: true
|
761
|
+
},
|
762
|
+
parentNode: {
|
763
|
+
get: function () {
|
764
|
+
return this.node._lightParent || (this.node.__patched ? this.node._composedParent : this.node.parentNode);
|
765
|
+
},
|
766
|
+
configurable: true
|
767
|
+
},
|
768
|
+
firstChild: {
|
769
|
+
get: function () {
|
770
|
+
return this.childNodes[0];
|
771
|
+
},
|
772
|
+
configurable: true
|
773
|
+
},
|
774
|
+
lastChild: {
|
775
|
+
get: function () {
|
776
|
+
var c$ = this.childNodes;
|
777
|
+
return c$[c$.length - 1];
|
778
|
+
},
|
779
|
+
configurable: true
|
780
|
+
},
|
781
|
+
nextSibling: {
|
782
|
+
get: function () {
|
783
|
+
var c$ = this.parentNode && factory(this.parentNode).childNodes;
|
784
|
+
if (c$) {
|
785
|
+
return c$[Array.prototype.indexOf.call(c$, this.node) + 1];
|
786
|
+
}
|
787
|
+
},
|
788
|
+
configurable: true
|
789
|
+
},
|
790
|
+
previousSibling: {
|
791
|
+
get: function () {
|
792
|
+
var c$ = this.parentNode && factory(this.parentNode).childNodes;
|
793
|
+
if (c$) {
|
794
|
+
return c$[Array.prototype.indexOf.call(c$, this.node) - 1];
|
795
|
+
}
|
796
|
+
},
|
797
|
+
configurable: true
|
798
|
+
},
|
799
|
+
firstElementChild: {
|
800
|
+
get: function () {
|
801
|
+
return this.children[0];
|
802
|
+
},
|
803
|
+
configurable: true
|
804
|
+
},
|
805
|
+
lastElementChild: {
|
806
|
+
get: function () {
|
807
|
+
var c$ = this.children;
|
808
|
+
return c$[c$.length - 1];
|
809
|
+
},
|
810
|
+
configurable: true
|
811
|
+
},
|
812
|
+
nextElementSibling: {
|
813
|
+
get: function () {
|
814
|
+
var c$ = this.parentNode && factory(this.parentNode).children;
|
815
|
+
if (c$) {
|
816
|
+
return c$[Array.prototype.indexOf.call(c$, this.node) + 1];
|
817
|
+
}
|
818
|
+
},
|
819
|
+
configurable: true
|
820
|
+
},
|
821
|
+
previousElementSibling: {
|
822
|
+
get: function () {
|
823
|
+
var c$ = this.parentNode && factory(this.parentNode).children;
|
824
|
+
if (c$) {
|
825
|
+
return c$[Array.prototype.indexOf.call(c$, this.node) - 1];
|
826
|
+
}
|
827
|
+
},
|
828
|
+
configurable: true
|
829
|
+
},
|
830
|
+
textContent: {
|
831
|
+
get: function () {
|
832
|
+
if (this.node.nodeType === Node.TEXT_NODE) {
|
833
|
+
return this.node.textContent;
|
834
|
+
} else {
|
835
|
+
return Array.prototype.map.call(this.childNodes, function (c) {
|
836
|
+
return c.textContent;
|
837
|
+
}).join('');
|
838
|
+
}
|
839
|
+
},
|
840
|
+
set: function (text) {
|
841
|
+
this._clear();
|
842
|
+
if (text) {
|
843
|
+
this.appendChild(document.createTextNode(text));
|
844
|
+
}
|
845
|
+
},
|
846
|
+
configurable: true
|
847
|
+
},
|
848
|
+
innerHTML: {
|
849
|
+
get: function () {
|
850
|
+
if (this.node.nodeType === Node.TEXT_NODE) {
|
851
|
+
return null;
|
852
|
+
} else {
|
853
|
+
return getInnerHTML(this.node);
|
854
|
+
}
|
855
|
+
},
|
856
|
+
set: function (text) {
|
857
|
+
if (this.node.nodeType !== Node.TEXT_NODE) {
|
858
|
+
this._clear();
|
859
|
+
var d = document.createElement('div');
|
860
|
+
d.innerHTML = text;
|
861
|
+
for (var e = d.firstChild; e; e = e.nextSibling) {
|
862
|
+
this.appendChild(e);
|
863
|
+
}
|
864
|
+
}
|
865
|
+
},
|
866
|
+
configurable: true
|
867
|
+
}
|
868
|
+
});
|
869
|
+
DomApi.prototype._getComposedInnerHTML = function () {
|
870
|
+
return getInnerHTML(this.node, true);
|
871
|
+
};
|
872
|
+
} else {
|
873
|
+
DomApi.prototype.querySelectorAll = function (selector) {
|
874
|
+
return Array.prototype.slice.call(this.node.querySelectorAll(selector));
|
875
|
+
};
|
876
|
+
DomApi.prototype.getOwnerRoot = function () {
|
877
|
+
var n = this.node;
|
878
|
+
while (n) {
|
879
|
+
if (n.nodeType === Node.DOCUMENT_FRAGMENT_NODE && n.host) {
|
880
|
+
return n;
|
881
|
+
}
|
882
|
+
n = n.parentNode;
|
883
|
+
}
|
884
|
+
};
|
885
|
+
DomApi.prototype.getDestinationInsertionPoints = function () {
|
886
|
+
var n$ = this.node.getDestinationInsertionPoints();
|
887
|
+
return n$ ? Array.prototype.slice.call(n$) : [];
|
888
|
+
};
|
889
|
+
DomApi.prototype.getDistributedNodes = function () {
|
890
|
+
var n$ = this.node.getDistributedNodes();
|
891
|
+
return n$ ? Array.prototype.slice.call(n$) : [];
|
892
|
+
};
|
893
|
+
DomApi.prototype._distributeParent = function () {
|
894
|
+
};
|
895
|
+
Object.defineProperties(DomApi.prototype, {
|
896
|
+
childNodes: {
|
897
|
+
get: function () {
|
898
|
+
return Array.prototype.slice.call(this.node.childNodes);
|
899
|
+
},
|
900
|
+
configurable: true
|
901
|
+
},
|
902
|
+
children: {
|
903
|
+
get: function () {
|
904
|
+
return Array.prototype.slice.call(this.node.children);
|
905
|
+
},
|
906
|
+
configurable: true
|
907
|
+
},
|
908
|
+
textContent: {
|
909
|
+
get: function () {
|
910
|
+
return this.node.textContent;
|
911
|
+
},
|
912
|
+
set: function (value) {
|
913
|
+
return this.node.textContent = value;
|
914
|
+
},
|
915
|
+
configurable: true
|
916
|
+
},
|
917
|
+
innerHTML: {
|
918
|
+
get: function () {
|
919
|
+
return this.node.innerHTML;
|
920
|
+
},
|
921
|
+
set: function (value) {
|
922
|
+
return this.node.innerHTML = value;
|
923
|
+
},
|
924
|
+
configurable: true
|
925
|
+
}
|
926
|
+
});
|
927
|
+
var forwards = [
|
928
|
+
'parentNode',
|
929
|
+
'firstChild',
|
930
|
+
'lastChild',
|
931
|
+
'nextSibling',
|
932
|
+
'previousSibling',
|
933
|
+
'firstElementChild',
|
934
|
+
'lastElementChild',
|
935
|
+
'nextElementSibling',
|
936
|
+
'previousElementSibling'
|
937
|
+
];
|
938
|
+
forwards.forEach(function (name) {
|
939
|
+
Object.defineProperty(DomApi.prototype, name, {
|
940
|
+
get: function () {
|
941
|
+
return this.node[name];
|
942
|
+
},
|
943
|
+
configurable: true
|
944
|
+
});
|
945
|
+
});
|
946
|
+
}
|
947
|
+
var CONTENT = 'content';
|
948
|
+
var factory = function (node, patch) {
|
949
|
+
node = node || document;
|
950
|
+
if (!node.__domApi) {
|
951
|
+
node.__domApi = new DomApi(node, patch);
|
952
|
+
}
|
953
|
+
return node.__domApi;
|
954
|
+
};
|
955
|
+
Polymer.dom = function (obj, patch) {
|
956
|
+
if (obj instanceof Event) {
|
957
|
+
return Polymer.EventApi.factory(obj);
|
958
|
+
} else {
|
959
|
+
return factory(obj, patch);
|
960
|
+
}
|
961
|
+
};
|
962
|
+
Polymer.dom.flush = DomApi.prototype.flush;
|
963
|
+
function getLightChildren(node) {
|
964
|
+
var children = node._lightChildren;
|
965
|
+
return children ? children : node.childNodes;
|
966
|
+
}
|
967
|
+
function getComposedChildren(node) {
|
968
|
+
if (!node._composedChildren) {
|
969
|
+
node._composedChildren = Array.prototype.slice.call(node.childNodes);
|
970
|
+
}
|
971
|
+
return node._composedChildren;
|
972
|
+
}
|
973
|
+
function addToComposedParent(parent, node, ref_node) {
|
974
|
+
var children = getComposedChildren(parent);
|
975
|
+
var i = ref_node ? children.indexOf(ref_node) : -1;
|
976
|
+
if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
|
977
|
+
var fragChildren = getComposedChildren(node);
|
978
|
+
fragChildren.forEach(function (c) {
|
979
|
+
addNodeToComposedChildren(c, parent, children, i);
|
980
|
+
});
|
981
|
+
} else {
|
982
|
+
addNodeToComposedChildren(node, parent, children, i);
|
983
|
+
}
|
984
|
+
}
|
985
|
+
function addNodeToComposedChildren(node, parent, children, i) {
|
986
|
+
node._composedParent = parent;
|
987
|
+
if (i >= 0) {
|
988
|
+
children.splice(i, 0, node);
|
989
|
+
} else {
|
990
|
+
children.push(node);
|
991
|
+
}
|
992
|
+
}
|
993
|
+
function removeFromComposedParent(parent, node) {
|
994
|
+
node._composedParent = null;
|
995
|
+
if (parent) {
|
996
|
+
var children = getComposedChildren(parent);
|
997
|
+
var i = children.indexOf(node);
|
998
|
+
if (i >= 0) {
|
999
|
+
children.splice(i, 1);
|
1000
|
+
}
|
1001
|
+
}
|
1002
|
+
}
|
1003
|
+
function saveLightChildrenIfNeeded(node) {
|
1004
|
+
if (!node._lightChildren) {
|
1005
|
+
var c$ = Array.prototype.slice.call(node.childNodes);
|
1006
|
+
for (var i = 0, l = c$.length, child; i < l && (child = c$[i]); i++) {
|
1007
|
+
child._lightParent = child._lightParent || node;
|
1008
|
+
}
|
1009
|
+
node._lightChildren = c$;
|
1010
|
+
}
|
1011
|
+
}
|
1012
|
+
function hasInsertionPoint(root) {
|
1013
|
+
return Boolean(root._insertionPoints.length);
|
1014
|
+
}
|
1015
|
+
var p = Element.prototype;
|
1016
|
+
var matchesSelector = p.matches || p.matchesSelector || p.mozMatchesSelector || p.msMatchesSelector || p.oMatchesSelector || p.webkitMatchesSelector;
|
1017
|
+
return {
|
1018
|
+
getLightChildren: getLightChildren,
|
1019
|
+
getComposedChildren: getComposedChildren,
|
1020
|
+
removeFromComposedParent: removeFromComposedParent,
|
1021
|
+
saveLightChildrenIfNeeded: saveLightChildrenIfNeeded,
|
1022
|
+
matchesSelector: matchesSelector,
|
1023
|
+
hasInsertionPoint: hasInsertionPoint,
|
1024
|
+
ctor: DomApi,
|
1025
|
+
factory: factory
|
1026
|
+
};
|
1027
|
+
}();
|
1028
|
+
(function () {
|
1029
|
+
Polymer.Base._addFeature({
|
1030
|
+
_prepShady: function () {
|
1031
|
+
this._useContent = this._useContent || Boolean(this._template);
|
1032
|
+
if (this._useContent) {
|
1033
|
+
this._template._hasInsertionPoint = this._template.content.querySelector('content');
|
1034
|
+
}
|
1035
|
+
},
|
1036
|
+
_poolContent: function () {
|
1037
|
+
if (this._useContent) {
|
1038
|
+
saveLightChildrenIfNeeded(this);
|
1039
|
+
}
|
1040
|
+
},
|
1041
|
+
_setupRoot: function () {
|
1042
|
+
if (this._useContent) {
|
1043
|
+
this._createLocalRoot();
|
1044
|
+
if (!this.dataHost) {
|
1045
|
+
upgradeLightChildren(this._lightChildren);
|
1046
|
+
}
|
1047
|
+
}
|
1048
|
+
},
|
1049
|
+
_createLocalRoot: function () {
|
1050
|
+
this.shadyRoot = this.root;
|
1051
|
+
this.shadyRoot._distributionClean = false;
|
1052
|
+
this.shadyRoot._isShadyRoot = true;
|
1053
|
+
this.shadyRoot._dirtyRoots = [];
|
1054
|
+
this.shadyRoot._insertionPoints = this._template._hasInsertionPoint ? this.shadyRoot.querySelectorAll('content') : [];
|
1055
|
+
saveLightChildrenIfNeeded(this.shadyRoot);
|
1056
|
+
this.shadyRoot.host = this;
|
1057
|
+
},
|
1058
|
+
get domHost() {
|
1059
|
+
var root = Polymer.dom(this).getOwnerRoot();
|
1060
|
+
return root && root.host;
|
1061
|
+
},
|
1062
|
+
distributeContent: function () {
|
1063
|
+
if (this.shadyRoot) {
|
1064
|
+
var host = getTopDistributingHost(this);
|
1065
|
+
Polymer.dom(this)._lazyDistribute(host);
|
1066
|
+
}
|
1067
|
+
},
|
1068
|
+
_distributeContent: function () {
|
1069
|
+
if (this._useContent && !this.shadyRoot._distributionClean) {
|
1070
|
+
this._beginDistribute();
|
1071
|
+
this._distributeDirtyRoots();
|
1072
|
+
this._finishDistribute();
|
1073
|
+
}
|
1074
|
+
},
|
1075
|
+
_beginDistribute: function () {
|
1076
|
+
if (this._useContent && hasInsertionPoint(this.shadyRoot)) {
|
1077
|
+
this._resetDistribution();
|
1078
|
+
this._distributePool(this.shadyRoot, this._collectPool());
|
1079
|
+
}
|
1080
|
+
},
|
1081
|
+
_distributeDirtyRoots: function () {
|
1082
|
+
var c$ = this.shadyRoot._dirtyRoots;
|
1083
|
+
for (var i = 0, l = c$.length, c; i < l && (c = c$[i]); i++) {
|
1084
|
+
c._distributeContent();
|
1085
|
+
}
|
1086
|
+
this.shadyRoot._dirtyRoots = [];
|
1087
|
+
},
|
1088
|
+
_finishDistribute: function () {
|
1089
|
+
if (this._useContent) {
|
1090
|
+
if (hasInsertionPoint(this.shadyRoot)) {
|
1091
|
+
this._composeTree();
|
1092
|
+
} else {
|
1093
|
+
if (!this.shadyRoot._hasDistributed) {
|
1094
|
+
this.textContent = '';
|
1095
|
+
this.appendChild(this.shadyRoot);
|
1096
|
+
} else {
|
1097
|
+
var children = this._composeNode(this);
|
1098
|
+
this._updateChildNodes(this, children);
|
1099
|
+
}
|
1100
|
+
}
|
1101
|
+
this.shadyRoot._hasDistributed = true;
|
1102
|
+
this.shadyRoot._distributionClean = true;
|
1103
|
+
}
|
1104
|
+
},
|
1105
|
+
elementMatches: function (selector, node) {
|
1106
|
+
node = node || this;
|
1107
|
+
return matchesSelector.call(node, selector);
|
1108
|
+
},
|
1109
|
+
_resetDistribution: function () {
|
1110
|
+
var children = getLightChildren(this);
|
1111
|
+
for (var i = 0; i < children.length; i++) {
|
1112
|
+
var child = children[i];
|
1113
|
+
if (child._destinationInsertionPoints) {
|
1114
|
+
child._destinationInsertionPoints = undefined;
|
1115
|
+
}
|
1116
|
+
if (isInsertionPoint(child)) {
|
1117
|
+
clearDistributedDestinationInsertionPoints(child);
|
1118
|
+
}
|
1119
|
+
}
|
1120
|
+
var root = this.shadyRoot;
|
1121
|
+
var p$ = root._insertionPoints;
|
1122
|
+
for (var j = 0; j < p$.length; j++) {
|
1123
|
+
p$[j]._distributedNodes = [];
|
1124
|
+
}
|
1125
|
+
},
|
1126
|
+
_collectPool: function () {
|
1127
|
+
var pool = [];
|
1128
|
+
var children = getLightChildren(this);
|
1129
|
+
for (var i = 0; i < children.length; i++) {
|
1130
|
+
var child = children[i];
|
1131
|
+
if (isInsertionPoint(child)) {
|
1132
|
+
pool.push.apply(pool, child._distributedNodes);
|
1133
|
+
} else {
|
1134
|
+
pool.push(child);
|
1135
|
+
}
|
1136
|
+
}
|
1137
|
+
return pool;
|
1138
|
+
},
|
1139
|
+
_distributePool: function (node, pool) {
|
1140
|
+
var p$ = node._insertionPoints;
|
1141
|
+
for (var i = 0, l = p$.length, p; i < l && (p = p$[i]); i++) {
|
1142
|
+
this._distributeInsertionPoint(p, pool);
|
1143
|
+
maybeRedistributeParent(p, this);
|
1144
|
+
}
|
1145
|
+
},
|
1146
|
+
_distributeInsertionPoint: function (content, pool) {
|
1147
|
+
var anyDistributed = false;
|
1148
|
+
for (var i = 0, l = pool.length, node; i < l; i++) {
|
1149
|
+
node = pool[i];
|
1150
|
+
if (!node) {
|
1151
|
+
continue;
|
1152
|
+
}
|
1153
|
+
if (this._matchesContentSelect(node, content)) {
|
1154
|
+
distributeNodeInto(node, content);
|
1155
|
+
pool[i] = undefined;
|
1156
|
+
anyDistributed = true;
|
1157
|
+
}
|
1158
|
+
}
|
1159
|
+
if (!anyDistributed) {
|
1160
|
+
var children = getLightChildren(content);
|
1161
|
+
for (var j = 0; j < children.length; j++) {
|
1162
|
+
distributeNodeInto(children[j], content);
|
1163
|
+
}
|
1164
|
+
}
|
1165
|
+
},
|
1166
|
+
_composeTree: function () {
|
1167
|
+
this._updateChildNodes(this, this._composeNode(this));
|
1168
|
+
var p$ = this.shadyRoot._insertionPoints;
|
1169
|
+
for (var i = 0, l = p$.length, p, parent; i < l && (p = p$[i]); i++) {
|
1170
|
+
parent = p._lightParent || p.parentNode;
|
1171
|
+
if (!parent._useContent && parent !== this && parent !== this.shadyRoot) {
|
1172
|
+
this._updateChildNodes(parent, this._composeNode(parent));
|
1173
|
+
}
|
1174
|
+
}
|
1175
|
+
},
|
1176
|
+
_composeNode: function (node) {
|
1177
|
+
var children = [];
|
1178
|
+
var c$ = getLightChildren(node.shadyRoot || node);
|
1179
|
+
for (var i = 0; i < c$.length; i++) {
|
1180
|
+
var child = c$[i];
|
1181
|
+
if (isInsertionPoint(child)) {
|
1182
|
+
var distributedNodes = child._distributedNodes;
|
1183
|
+
for (var j = 0; j < distributedNodes.length; j++) {
|
1184
|
+
var distributedNode = distributedNodes[j];
|
1185
|
+
if (isFinalDestination(child, distributedNode)) {
|
1186
|
+
children.push(distributedNode);
|
1187
|
+
}
|
1188
|
+
}
|
1189
|
+
} else {
|
1190
|
+
children.push(child);
|
1191
|
+
}
|
1192
|
+
}
|
1193
|
+
return children;
|
1194
|
+
},
|
1195
|
+
_updateChildNodes: function (container, children) {
|
1196
|
+
var composed = getComposedChildren(container);
|
1197
|
+
var splices = Polymer.ArraySplice.calculateSplices(children, composed);
|
1198
|
+
for (var i = 0, d = 0, s; i < splices.length && (s = splices[i]); i++) {
|
1199
|
+
for (var j = 0, n; j < s.removed.length && (n = s.removed[j]); j++) {
|
1200
|
+
remove(n);
|
1201
|
+
composed.splice(s.index + d, 1);
|
1202
|
+
}
|
1203
|
+
d -= s.addedCount;
|
1204
|
+
}
|
1205
|
+
for (var i = 0, s, next; i < splices.length && (s = splices[i]); i++) {
|
1206
|
+
next = composed[s.index];
|
1207
|
+
for (var j = s.index, n; j < s.index + s.addedCount; j++) {
|
1208
|
+
n = children[j];
|
1209
|
+
insertBefore(container, n, next);
|
1210
|
+
composed.splice(j, 0, n);
|
1211
|
+
}
|
1212
|
+
}
|
1213
|
+
},
|
1214
|
+
_matchesContentSelect: function (node, contentElement) {
|
1215
|
+
var select = contentElement.getAttribute('select');
|
1216
|
+
if (!select) {
|
1217
|
+
return true;
|
1218
|
+
}
|
1219
|
+
select = select.trim();
|
1220
|
+
if (!select) {
|
1221
|
+
return true;
|
1222
|
+
}
|
1223
|
+
if (!(node instanceof Element)) {
|
1224
|
+
return false;
|
1225
|
+
}
|
1226
|
+
var validSelectors = /^(:not\()?[*.#[a-zA-Z_|]/;
|
1227
|
+
if (!validSelectors.test(select)) {
|
1228
|
+
return false;
|
1229
|
+
}
|
1230
|
+
return this.elementMatches(select, node);
|
1231
|
+
},
|
1232
|
+
_elementAdd: function () {
|
1233
|
+
},
|
1234
|
+
_elementRemove: function () {
|
1235
|
+
}
|
1236
|
+
});
|
1237
|
+
var saveLightChildrenIfNeeded = Polymer.DomApi.saveLightChildrenIfNeeded;
|
1238
|
+
var getLightChildren = Polymer.DomApi.getLightChildren;
|
1239
|
+
var matchesSelector = Polymer.DomApi.matchesSelector;
|
1240
|
+
var hasInsertionPoint = Polymer.DomApi.hasInsertionPoint;
|
1241
|
+
var getComposedChildren = Polymer.DomApi.getComposedChildren;
|
1242
|
+
var removeFromComposedParent = Polymer.DomApi.removeFromComposedParent;
|
1243
|
+
function distributeNodeInto(child, insertionPoint) {
|
1244
|
+
insertionPoint._distributedNodes.push(child);
|
1245
|
+
var points = child._destinationInsertionPoints;
|
1246
|
+
if (!points) {
|
1247
|
+
child._destinationInsertionPoints = [insertionPoint];
|
1248
|
+
} else {
|
1249
|
+
points.push(insertionPoint);
|
1250
|
+
}
|
1251
|
+
}
|
1252
|
+
function clearDistributedDestinationInsertionPoints(content) {
|
1253
|
+
var e$ = content._distributedNodes;
|
1254
|
+
for (var i = 0; i < e$.length; i++) {
|
1255
|
+
var d = e$[i]._destinationInsertionPoints;
|
1256
|
+
if (d) {
|
1257
|
+
d.splice(d.indexOf(content) + 1, d.length);
|
1258
|
+
}
|
1259
|
+
}
|
1260
|
+
}
|
1261
|
+
function maybeRedistributeParent(content, host) {
|
1262
|
+
var parent = content._lightParent;
|
1263
|
+
if (parent && parent.shadyRoot && hasInsertionPoint(parent.shadyRoot) && parent.shadyRoot._distributionClean) {
|
1264
|
+
parent.shadyRoot._distributionClean = false;
|
1265
|
+
host.shadyRoot._dirtyRoots.push(parent);
|
1266
|
+
}
|
1267
|
+
}
|
1268
|
+
function isFinalDestination(insertionPoint, node) {
|
1269
|
+
var points = node._destinationInsertionPoints;
|
1270
|
+
return points && points[points.length - 1] === insertionPoint;
|
1271
|
+
}
|
1272
|
+
function isInsertionPoint(node) {
|
1273
|
+
return node.localName == 'content';
|
1274
|
+
}
|
1275
|
+
var nativeInsertBefore = Element.prototype.insertBefore;
|
1276
|
+
var nativeRemoveChild = Element.prototype.removeChild;
|
1277
|
+
function insertBefore(parentNode, newChild, refChild) {
|
1278
|
+
var newChildParent = getComposedParent(newChild);
|
1279
|
+
if (newChildParent !== parentNode) {
|
1280
|
+
removeFromComposedParent(newChildParent, newChild);
|
1281
|
+
}
|
1282
|
+
remove(newChild);
|
1283
|
+
saveLightChildrenIfNeeded(parentNode);
|
1284
|
+
nativeInsertBefore.call(parentNode, newChild, refChild || null);
|
1285
|
+
newChild._composedParent = parentNode;
|
1286
|
+
}
|
1287
|
+
function remove(node) {
|
1288
|
+
var parentNode = getComposedParent(node);
|
1289
|
+
if (parentNode) {
|
1290
|
+
saveLightChildrenIfNeeded(parentNode);
|
1291
|
+
node._composedParent = null;
|
1292
|
+
nativeRemoveChild.call(parentNode, node);
|
1293
|
+
}
|
1294
|
+
}
|
1295
|
+
function getComposedParent(node) {
|
1296
|
+
return node.__patched ? node._composedParent : node.parentNode;
|
1297
|
+
}
|
1298
|
+
function getTopDistributingHost(host) {
|
1299
|
+
while (host && hostNeedsRedistribution(host)) {
|
1300
|
+
host = host.domHost;
|
1301
|
+
}
|
1302
|
+
return host;
|
1303
|
+
}
|
1304
|
+
function hostNeedsRedistribution(host) {
|
1305
|
+
var c$ = Polymer.dom(host).children;
|
1306
|
+
for (var i = 0, c; i < c$.length; i++) {
|
1307
|
+
c = c$[i];
|
1308
|
+
if (c.localName === 'content') {
|
1309
|
+
return host.domHost;
|
1310
|
+
}
|
1311
|
+
}
|
1312
|
+
}
|
1313
|
+
var needsUpgrade = window.CustomElements && !CustomElements.useNative;
|
1314
|
+
function upgradeLightChildren(children) {
|
1315
|
+
if (needsUpgrade && children) {
|
1316
|
+
for (var i = 0; i < children.length; i++) {
|
1317
|
+
CustomElements.upgrade(children[i]);
|
1318
|
+
}
|
1319
|
+
}
|
1320
|
+
}
|
1321
|
+
}());
|
1322
|
+
if (Polymer.Settings.useShadow) {
|
1323
|
+
Polymer.Base._addFeature({
|
1324
|
+
_poolContent: function () {
|
1325
|
+
},
|
1326
|
+
_beginDistribute: function () {
|
1327
|
+
},
|
1328
|
+
distributeContent: function () {
|
1329
|
+
},
|
1330
|
+
_distributeContent: function () {
|
1331
|
+
},
|
1332
|
+
_finishDistribute: function () {
|
1333
|
+
},
|
1334
|
+
_createLocalRoot: function () {
|
1335
|
+
this.createShadowRoot();
|
1336
|
+
this.shadowRoot.appendChild(this.root);
|
1337
|
+
this.root = this.shadowRoot;
|
1338
|
+
}
|
1339
|
+
});
|
1340
|
+
}
|
1341
|
+
Polymer.DomModule = document.createElement('dom-module');
|
1342
|
+
Polymer.Base._addFeature({
|
1343
|
+
_registerFeatures: function () {
|
1344
|
+
this._prepIs();
|
1345
|
+
this._prepAttributes();
|
1346
|
+
this._prepBehaviors();
|
1347
|
+
this._prepExtends();
|
1348
|
+
this._prepConstructor();
|
1349
|
+
this._prepTemplate();
|
1350
|
+
this._prepShady();
|
1351
|
+
},
|
1352
|
+
_prepBehavior: function (b) {
|
1353
|
+
this._addHostAttributes(b.hostAttributes);
|
1354
|
+
},
|
1355
|
+
_initFeatures: function () {
|
1356
|
+
this._poolContent();
|
1357
|
+
this._pushHost();
|
1358
|
+
this._stampTemplate();
|
1359
|
+
this._popHost();
|
1360
|
+
this._marshalHostAttributes();
|
1361
|
+
this._setupDebouncers();
|
1362
|
+
this._marshalBehaviors();
|
1363
|
+
this._tryReady();
|
1364
|
+
},
|
1365
|
+
_marshalBehavior: function (b) {
|
1366
|
+
}
|
1367
|
+
});</script>
|
1368
|
+
|