leanweb 1.2.5 → 1.2.8
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/README.md
CHANGED
|
@@ -324,14 +324,13 @@ imageWidth = 400;
|
|
|
324
324
|
`demo-parent.html`
|
|
325
325
|
|
|
326
326
|
```html
|
|
327
|
-
<demo-child lw-input:parent="
|
|
327
|
+
<demo-child lw-input:parent="this" lw-input:userData="user"></demo-child>
|
|
328
328
|
```
|
|
329
329
|
|
|
330
330
|
`demo-parent.js`
|
|
331
331
|
|
|
332
332
|
```javascript
|
|
333
333
|
// ...
|
|
334
|
-
// self is defined in LWElement as `self = this`;
|
|
335
334
|
user = { firstname: "Qian", lastname: "Chen" };
|
|
336
335
|
// ...
|
|
337
336
|
```
|
|
@@ -388,7 +387,6 @@ checkedValues = [];
|
|
|
388
387
|
checked = false;
|
|
389
388
|
toggleCheckbox() {
|
|
390
389
|
this.checked = !this.checked;
|
|
391
|
-
this.update();
|
|
392
390
|
}
|
|
393
391
|
```
|
|
394
392
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "leanweb",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.8",
|
|
4
4
|
"description": "Builds framework agnostic web components.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"leanweb": "leanweb.js",
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"node-watch": "^0.7.3",
|
|
36
36
|
"parse5": "^7.0.0",
|
|
37
37
|
"raw-loader": "^4.0.2",
|
|
38
|
-
"sass": "^1.54.
|
|
38
|
+
"sass": "^1.54.4",
|
|
39
39
|
"sass-loader": "^13.0.2",
|
|
40
40
|
"semver": "^7.3.7",
|
|
41
41
|
"webpack": "^5.74.0",
|
|
42
|
-
"webpack-dev-server": "^4.
|
|
42
|
+
"webpack-dev-server": "^4.10.0"
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -77,6 +77,7 @@ globalThis.addEventListener('hashchange', () => {
|
|
|
77
77
|
leanweb.componentsListeningOnUrlChanges.forEach(component => {
|
|
78
78
|
setTimeout(() => {
|
|
79
79
|
component?.urlHashChanged?.call(component);
|
|
80
|
+
component?.update?.call(component);
|
|
80
81
|
});
|
|
81
82
|
});
|
|
82
83
|
}, false);
|
|
@@ -97,7 +98,6 @@ const nextAllSiblings = (el, selector) => {
|
|
|
97
98
|
};
|
|
98
99
|
|
|
99
100
|
export default class LWElement extends HTMLElement {
|
|
100
|
-
self = this;
|
|
101
101
|
constructor(ast) {
|
|
102
102
|
super();
|
|
103
103
|
this.ast = ast;
|
|
@@ -133,7 +133,7 @@ export default class LWElement extends HTMLElement {
|
|
|
133
133
|
|
|
134
134
|
_getNodeContext(node) {
|
|
135
135
|
const contextNode = node.closest('[lw-context]');
|
|
136
|
-
return contextNode?.['lw-context'] ?? [this, globalThis];
|
|
136
|
+
return contextNode?.['lw-context'] ?? [{ 'this': this }, this, globalThis];
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
update(rootNode = this.shadowRoot) {
|
|
@@ -127,6 +127,14 @@ const nodeHandlers = {
|
|
|
127
127
|
return context[node.name];
|
|
128
128
|
}
|
|
129
129
|
},
|
|
130
|
+
'ThisExpression': (node, context) => {
|
|
131
|
+
if (Array.isArray(context)) {
|
|
132
|
+
const hitContext = context.find(contextObj => 'this' in contextObj);
|
|
133
|
+
return hitContext ? hitContext['this'] : undefined;
|
|
134
|
+
} else if (typeof context === 'object') {
|
|
135
|
+
return context['this'];
|
|
136
|
+
}
|
|
137
|
+
},
|
|
130
138
|
|
|
131
139
|
'CallExpression': (node, context) => callFunction(node, context),
|
|
132
140
|
'OptionalCallExpression': (node, context) => callFunction(node, context),
|