leanweb 1.3.0 → 1.3.1
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.
- package/package.json +1 -1
- package/templates/lib/lw-element.js +19 -17
package/package.json
CHANGED
|
@@ -143,7 +143,6 @@ export default class LWElement extends HTMLElement {
|
|
|
143
143
|
this._bindModels(rootNode);
|
|
144
144
|
this._bindEvents(rootNode);
|
|
145
145
|
this._bindInputs(rootNode);
|
|
146
|
-
rootNode.removeAttribute('lw-elem-bind');
|
|
147
146
|
}
|
|
148
147
|
if (rootNode.hasAttribute('lw-if')) {
|
|
149
148
|
this.updateIf(rootNode);
|
|
@@ -162,11 +161,17 @@ export default class LWElement extends HTMLElement {
|
|
|
162
161
|
const treeWalker = document.createTreeWalker(rootNode, NodeFilter.SHOW_ELEMENT, {
|
|
163
162
|
acceptNode: node => {
|
|
164
163
|
if (node.hasAttribute('lw-elem')) {
|
|
164
|
+
if (node.hasAttribute('lw-for')) {
|
|
165
|
+
this.updateFor(node);
|
|
166
|
+
return NodeFilter.FILTER_REJECT;
|
|
167
|
+
}
|
|
168
|
+
if (node.hasAttribute('lw-for-parent')) {
|
|
169
|
+
return NodeFilter.FILTER_REJECT;
|
|
170
|
+
}
|
|
165
171
|
if (node.hasAttribute('lw-elem-bind')) {
|
|
166
172
|
this._bindModels(node);
|
|
167
173
|
this._bindEvents(node);
|
|
168
174
|
this._bindInputs(node);
|
|
169
|
-
node.removeAttribute('lw-elem-bind');
|
|
170
175
|
}
|
|
171
176
|
if (node.hasAttribute('lw-if')) {
|
|
172
177
|
this.updateIf(node);
|
|
@@ -174,13 +179,6 @@ export default class LWElement extends HTMLElement {
|
|
|
174
179
|
if (node.hasAttribute('lw-false')) {
|
|
175
180
|
return NodeFilter.FILTER_REJECT;
|
|
176
181
|
}
|
|
177
|
-
if (node.hasAttribute('lw-for-parent')) {
|
|
178
|
-
return NodeFilter.FILTER_REJECT;
|
|
179
|
-
}
|
|
180
|
-
if (node.hasAttribute('lw-for')) {
|
|
181
|
-
this.updateFor(node);
|
|
182
|
-
return NodeFilter.FILTER_REJECT;
|
|
183
|
-
}
|
|
184
182
|
this.updateEval(node);
|
|
185
183
|
this.updateClass(node);
|
|
186
184
|
this.updateBind(node);
|
|
@@ -203,6 +201,10 @@ export default class LWElement extends HTMLElement {
|
|
|
203
201
|
}
|
|
204
202
|
|
|
205
203
|
_bindInputs(inputNode) {
|
|
204
|
+
if (inputNode['lw_input_bound']) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
inputNode['lw_input_bound'] = true;
|
|
206
208
|
for (const attr of inputNode.attributes) {
|
|
207
209
|
const attrName = attr.name;
|
|
208
210
|
const attrValue = attr.value;
|
|
@@ -218,17 +220,17 @@ export default class LWElement extends HTMLElement {
|
|
|
218
220
|
}
|
|
219
221
|
|
|
220
222
|
// properties:
|
|
221
|
-
//
|
|
223
|
+
// lw_event_bound: boolean
|
|
222
224
|
_bindEvents(eventNode) {
|
|
225
|
+
if (eventNode['lw_event_bound']) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
eventNode['lw_event_bound'] = true;
|
|
223
229
|
const me = this;
|
|
224
230
|
for (const attr of eventNode.attributes) {
|
|
225
231
|
const attrName = attr.name;
|
|
226
232
|
const attrValue = attr.value;
|
|
227
233
|
if (attrName.startsWith('lw-on:')) {
|
|
228
|
-
if (eventNode[attrName]) {
|
|
229
|
-
continue;
|
|
230
|
-
}
|
|
231
|
-
eventNode[attrName] = true;
|
|
232
234
|
const interpolation = this.ast[attrValue];
|
|
233
235
|
interpolation.lwValue.split(',').forEach(eventType => {
|
|
234
236
|
eventNode.addEventListener(eventType.trim(), (event => {
|
|
@@ -250,16 +252,16 @@ export default class LWElement extends HTMLElement {
|
|
|
250
252
|
}
|
|
251
253
|
|
|
252
254
|
// properties:
|
|
253
|
-
//
|
|
255
|
+
// lw_model_bound: boolean
|
|
254
256
|
_bindModels(modelNode) {
|
|
255
257
|
const key = modelNode.getAttribute('lw-model');
|
|
256
258
|
if (!key) {
|
|
257
259
|
return;
|
|
258
260
|
}
|
|
259
|
-
if (modelNode['
|
|
261
|
+
if (modelNode['lw_model_bound']) {
|
|
260
262
|
return;
|
|
261
263
|
}
|
|
262
|
-
modelNode['
|
|
264
|
+
modelNode['lw_model_bound'] = true;
|
|
263
265
|
const interpolation = this.ast[key];
|
|
264
266
|
modelNode.addEventListener('input', (event => {
|
|
265
267
|
const context = this._getNodeContext(modelNode);
|