Skip to content

Commit 68738ea

Browse files
committed
fix: native tag default event handlers spread
1 parent 9cf4757 commit 68738ea

14 files changed

Lines changed: 248 additions & 1 deletion

File tree

.changeset/ready-jars-switch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@marko/runtime-tags": patch
3+
---
4+
5+
Fix issue with registering default event handlers before a spread on a native tag.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"vars": {
3+
"props": {
4+
"$_": "r",
5+
"$init": "m",
6+
"$_2": "t"
7+
}
8+
}
9+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Render
2+
```html
3+
<button />
4+
```
5+
6+
7+
# Render
8+
```js
9+
container.querySelector("button").click();
10+
```
11+
```html
12+
<button>
13+
clicked
14+
</button>
15+
```
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Render
2+
```html
3+
<button />
4+
```
5+
6+
# Mutations
7+
```
8+
INSERT button
9+
```
10+
11+
# Render
12+
```js
13+
container.querySelector("button").click();
14+
```
15+
```html
16+
<button>
17+
clicked
18+
</button>
19+
```
20+
21+
# Mutations
22+
```
23+
INSERT button/#text
24+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// size: 101 (min) 88 (brotli)
2+
(_2._script("a1", ($scope) => _2._attrs_script($scope, "a")),
3+
_2._resume("a0", function (_, el) {
4+
el.textContent = "clicked";
5+
}),
6+
init());
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
export const $template = "<button></button>";
2+
export const $walks = /* get, over(1) */" b";
3+
export const $setup = () => {};
4+
import * as _2 from "@marko/runtime-tags/debug/dom";
5+
const $rest__script = _2._script("__tests__/template.marko_0_rest", $scope => _2._attrs_script($scope, "#button/0"));
6+
export const $rest = /* @__PURE__ */_2._const("rest", $scope => {
7+
_2._attrs_content($scope, "#button/0", {
8+
onClick: $onClick,
9+
...$scope.rest
10+
});
11+
$rest__script($scope);
12+
});
13+
export const $input = ($scope, input) => (({
14+
onClick,
15+
...rest
16+
}) => $rest($scope, rest))(input);
17+
function $onClick(_, el) {
18+
el.textContent = "clicked";
19+
}
20+
_2._resume("__tests__/template.marko_0/onClick", $onClick);
21+
export default /* @__PURE__ */_2._template("__tests__/template.marko", $template, $walks, $setup, $input);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import * as _2 from "@marko/runtime-tags/debug/html";
2+
export default _2._template("__tests__/template.marko", input => {
3+
const $scope0_id = _2._scope_id();
4+
const {
5+
onClick,
6+
...rest
7+
} = input;
8+
_2._html("<button");
9+
_2._attrs_content({
10+
onClick: _2._resume(function (_, el) {
11+
el.textContent = "clicked";
12+
}, "__tests__/template.marko_0/onClick"),
13+
...rest
14+
}, "#button/0", $scope0_id, "button");
15+
_2._html(`</button>${_2._el_resume($scope0_id, "#button/0")}`);
16+
_2._script($scope0_id, "__tests__/template.marko_0_rest");
17+
_2._scope($scope0_id, {
18+
rest
19+
}, "__tests__/template.marko", 0, {
20+
rest: "1:22"
21+
});
22+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Render
2+
```html
3+
<button />
4+
```
5+
6+
7+
# Render
8+
```js
9+
container.querySelector("button").click();
10+
```
11+
```html
12+
<button>
13+
clicked
14+
</button>
15+
```
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Render
2+
```html
3+
<html>
4+
<head />
5+
<body>
6+
<button />
7+
<!--M_*1 #button/0-->
8+
<script>
9+
WALKER_RUNTIME("M")("_");
10+
M._.r = [_ =&gt; (_.a = [0,
11+
{
12+
"EventAttributes:#button/0":
13+
{
14+
click: _._[
15+
"__tests__/template.marko_0/onClick"
16+
]
17+
},
18+
rest:
19+
{}
20+
}]),
21+
"__tests__/template.marko_0_rest 1"
22+
];
23+
M._.w()
24+
</script>
25+
</body>
26+
</html>
27+
```
28+
29+
30+
# Render
31+
```js
32+
container.querySelector("button").click();
33+
```
34+
```html
35+
<html>
36+
<head />
37+
<body>
38+
<button>
39+
clicked
40+
</button>
41+
<!--M_*1 #button/0-->
42+
<script>
43+
WALKER_RUNTIME("M")("_");
44+
M._.r = [_ =&gt; (_.a = [0,
45+
{
46+
"EventAttributes:#button/0":
47+
{
48+
click: _._[
49+
"__tests__/template.marko_0/onClick"
50+
]
51+
},
52+
rest:
53+
{}
54+
}]),
55+
"__tests__/template.marko_0_rest 1"
56+
];
57+
M._.w()
58+
</script>
59+
</body>
60+
</html>
61+
```
62+
63+
# Mutations
64+
```
65+
INSERT html/body/button/#text
66+
```
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Render End
2+
```html
3+
<button />
4+
```

0 commit comments

Comments
 (0)