mirror of
https://github.com/marko-js/marko.git
synced 2026-02-01 16:07:13 +00:00
fix: ensure only child optimization ignores comments (#3012)
* fix: ensure only child optimization ignores comments * chore: add changeset
This commit is contained in:
parent
9b26913239
commit
7ec9683b16
5
.changeset/clever-chicken-drum.md
Normal file
5
.changeset/clever-chicken-drum.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"@marko/runtime-tags": patch
|
||||
---
|
||||
|
||||
Ignore comments for only child conditional optimization
|
||||
@ -9,7 +9,7 @@ export default _._template("__tests__/template.marko", input => {
|
||||
_._html(`<span>${_._escape(value)}${_._el_resume($scope1_id, "#text/0")}</span>`);
|
||||
_._scope($scope1_id, {
|
||||
_: _._scope_with_id($scope0_id)
|
||||
}, "__tests__/template.marko", "3:4");
|
||||
}, "__tests__/template.marko", "4:4");
|
||||
return 0;
|
||||
}
|
||||
}, $scope0_id, "#div/0", 1, /* value */1, /* value */1, "</div>", 1);
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<let/value=input.value>
|
||||
<div>
|
||||
// This comment shouldn't count as a child!
|
||||
<if=value>
|
||||
<span>${value}</span>
|
||||
</if>
|
||||
|
||||
@ -29,7 +29,9 @@ export function getOnlyChildParentTagName(
|
||||
parentTag &&
|
||||
getTagDef(parentTag)?.html &&
|
||||
parentTag.node.name.type === "StringLiteral" &&
|
||||
(tag.parent as t.MarkoTagBody).body.length === branchSize
|
||||
(tag.parent as t.MarkoTagBody).body.filter(
|
||||
(node) => node.type !== "MarkoComment",
|
||||
).length === branchSize
|
||||
? parentTag.node.name.value
|
||||
: false);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user