Skip to content

Commit 3e55ba6

Browse files
authored
fix(dynamic-tag): stricter normalization (#2868)
* fix(dynamic-tag): stricter normalization * chore: add changeset
1 parent 1e75400 commit 3e55ba6

File tree

18 files changed

+145
-5
lines changed

18 files changed

+145
-5
lines changed

.changeset/sixty-fans-repair.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@marko/runtime-tags": patch
3+
"@marko/translator-interop-class-tags": patch
4+
---
5+
6+
Increase specificity of dynamic tag normalization

.sizes.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
{
88
"name": "*",
99
"total": {
10-
"min": 19308,
11-
"brotli": 7346
10+
"min": 19360,
11+
"brotli": 7338
1212
}
1313
},
1414
{

.sizes/dom.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// size: 19308 (min) 7346 (brotli)
1+
// size: 19360 (min) 7338 (brotli)
22
var empty = [],
33
rest = Symbol();
44
function attrTag(attrs) {
@@ -69,7 +69,11 @@ function getEventHandlerName(name) {
6969
return "-" === name[2] ? name.slice(3) : name.slice(2).toLowerCase();
7070
}
7171
function normalizeDynamicRenderer(value) {
72-
return value ? value.content || value.default || value : void 0;
72+
if (value) {
73+
if ("string" == typeof value) return value;
74+
let normalized = value.content || value.default || value;
75+
if ("___id" in normalized) return normalized;
76+
}
7377
}
7478
var defaultDelegator = createDelegator();
7579
function _on(element, type, handler) {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"vars": {
3+
"props": {}
4+
}
5+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Render
2+
```html
3+
<div />
4+
<div>
5+
Hello
6+
</div>
7+
```
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Render
2+
```html
3+
<div />
4+
<div>
5+
Hello
6+
</div>
7+
```
8+
9+
# Mutations
10+
```
11+
INSERT div0, div1
12+
```
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export const $template = "<div><!></div>";
2+
export const $walks = /* next(1), replace, out(1) */"D%l";
3+
export const $setup = () => {};
4+
import * as _ from "@marko/runtime-tags/debug/dom";
5+
const $dynamicTag = /* @__PURE__ */_._dynamic_tag("#text/0");
6+
export const $input = /* @__PURE__ */_._const("input", $dynamicTag);
7+
export default /* @__PURE__ */_._template("__tests__/tags/child.marko", $template, $walks, $setup, $input);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// size: 0
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export const $template = `${_child_template}${_child_template}`;
2+
export const $walks = /* beginChild, _child_walks, endChild, beginChild, _child_walks, endChild */`/${_child_walks}&/${_child_walks}&`;
3+
import { $setup as _child, $input as _child_input, $template as _child_template, $walks as _child_walks } from "./tags/child.marko";
4+
import * as _ from "@marko/runtime-tags/debug/dom";
5+
const $child_content = /* @__PURE__ */_._content("__tests__/template.marko_1_content", "Hello", /* over(1) */"b");
6+
export function $setup($scope) {
7+
_child($scope["#childScope/0"]);
8+
_child_input($scope["#childScope/0"], {});
9+
_child($scope["#childScope/1"]);
10+
_child_input($scope["#childScope/1"], {
11+
content: $child_content($scope)
12+
});
13+
}
14+
export default /* @__PURE__ */_._template("__tests__/template.marko", $template, $walks, $setup);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import * as _ from "@marko/runtime-tags/debug/html";
2+
export default _._template("__tests__/tags/child.marko", input => {
3+
const $serialize = _._get_serialize_reason();
4+
const $scope0_id = _._scope_id();
5+
_._html("<div>");
6+
_._dynamic_tag($scope0_id, "#text/0", input, {}, 0, 0, _._serialize_guard($serialize, /* input */0));
7+
_._html("</div>");
8+
_._serialize_guard($serialize, /* input */0) && _._scope($scope0_id, {}, "__tests__/tags/child.marko", 0);
9+
});

0 commit comments

Comments
 (0)