-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8503f18
commit 81a9316
Showing
16 changed files
with
998 additions
and
1,242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"marko-widgets": patch | ||
"@marko/compat-v4": patch | ||
--- | ||
|
||
Fix compat with latest @marko/compiler attribute tags changes. |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { isAttributeTag, isTransparentTag } from "@marko/babel-utils"; | ||
import { types as t } from "@marko/compiler"; | ||
|
||
export default { | ||
Program: { | ||
exit(program) { | ||
for (const child of program.get("body")) { | ||
if (child.isMarkoTag()) { | ||
hoistAttrTags(child); | ||
} | ||
} | ||
}, | ||
}, | ||
} satisfies t.Visitor; | ||
|
||
function hoistAttrTags(tag: t.NodePath<t.MarkoTag>) { | ||
let hadAttrTags = false; | ||
const isControlFlow = isTransparentTag(tag); | ||
const body = tag.get("body"); | ||
for (const child of body.get("body")) { | ||
if (child.isMarkoTag()) { | ||
const hoistedChildren = hoistAttrTags(child); | ||
if ( | ||
isAttributeTag(child) || | ||
(isTransparentTag(child) && hoistedChildren) | ||
) { | ||
if (!isControlFlow) { | ||
tag.pushContainer("attributeTags", child.node); | ||
child.remove(); | ||
} | ||
hadAttrTags = true; | ||
} | ||
} | ||
} | ||
|
||
if (isControlFlow && hadAttrTags) { | ||
body.node.attributeTags = true; | ||
} | ||
|
||
return hadAttrTags; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,7 @@ export default { | |
node.body, | ||
node.arguments, | ||
node.var, | ||
node.attributeTags, | ||
), | ||
); | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.