diff --git a/.changeset/nine-pumas-raise.md b/.changeset/nine-pumas-raise.md
new file mode 100644
index 0000000..71ee143
--- /dev/null
+++ b/.changeset/nine-pumas-raise.md
@@ -0,0 +1,5 @@
+---
+"@marko/tags-api-preview": patch
+---
+
+Fix issue with cached values inside attribute tags.
diff --git a/src/__tests__/fixtures/misc/attribute-tags/__snapshots__/misc-attribute-tags/single/node.render.expected.html b/src/__tests__/fixtures/misc/attribute-tags/__snapshots__/misc-attribute-tags/single/node.render.expected.html
new file mode 100644
index 0000000..ba77883
--- /dev/null
+++ b/src/__tests__/fixtures/misc/attribute-tags/__snapshots__/misc-attribute-tags/single/node.render.expected.html
@@ -0,0 +1,18 @@
+
+ Hello Frank!
+
+
+ Hello Frank!
+
+
+ Hello John!
+
\ No newline at end of file
diff --git a/src/__tests__/fixtures/misc/attribute-tags/__snapshots__/misc-attribute-tags/single/web.render.expected.html b/src/__tests__/fixtures/misc/attribute-tags/__snapshots__/misc-attribute-tags/single/web.render.expected.html
new file mode 100644
index 0000000..ba77883
--- /dev/null
+++ b/src/__tests__/fixtures/misc/attribute-tags/__snapshots__/misc-attribute-tags/single/web.render.expected.html
@@ -0,0 +1,18 @@
+
+ Hello Frank!
+
+
+ Hello Frank!
+
+
+ Hello John!
+
\ No newline at end of file
diff --git a/src/__tests__/fixtures/misc/attribute-tags/components/test.marko b/src/__tests__/fixtures/misc/attribute-tags/components/test.marko
new file mode 100644
index 0000000..ac1a32e
--- /dev/null
+++ b/src/__tests__/fixtures/misc/attribute-tags/components/test.marko
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+ <${item}/>
+
+
+
+
+
+ <${value}/>
+
+
+
+
diff --git a/src/__tests__/fixtures/misc/attribute-tags/index.test.ts b/src/__tests__/fixtures/misc/attribute-tags/index.test.ts
new file mode 100644
index 0000000..5aca3cb
--- /dev/null
+++ b/src/__tests__/fixtures/misc/attribute-tags/index.test.ts
@@ -0,0 +1,5 @@
+import fixture from "../../../fixture";
+
+describe("misc attribute tags", () => {
+ describe("single", fixture("./templates/single.marko"));
+});
diff --git a/src/__tests__/fixtures/misc/attribute-tags/templates/single.marko b/src/__tests__/fixtures/misc/attribute-tags/templates/single.marko
new file mode 100644
index 0000000..757436d
--- /dev/null
+++ b/src/__tests__/fixtures/misc/attribute-tags/templates/single.marko
@@ -0,0 +1,17 @@
+
+
+ <@hello name="Frank" onClick() {
+ console.log('Hello Frank!');
+ }>
+ Hello Frank!
+ @hello>
+
+
+
+ <@hello name=name onClick() {
+ console.log('Hello ' + name + '!');
+ }>
+ Hello ${name}!
+ @hello>
+
+
diff --git a/src/transform/wrapper-component.ts b/src/transform/wrapper-component.ts
index 3a9ef41..dc2525d 100644
--- a/src/transform/wrapper-component.ts
+++ b/src/transform/wrapper-component.ts
@@ -1,5 +1,11 @@
import { types as t } from "@marko/compiler";
-import { isNativeTag, getTagDef } from "@marko/babel-utils";
+import {
+ isNativeTag,
+ isTransparentTag,
+ isAttributeTag,
+ findParentTag,
+ getTagDef,
+} from "@marko/babel-utils";
import { taglibId } from "../util/taglib-id";
import isApi from "../util/is-api";
@@ -96,6 +102,14 @@ export function ensureLifecycle(tag: t.NodePath, client = true) {
isNativeTag(root as t.NodePath)
);
+ if (isAttributeTagLike(tag)) {
+ if (isTransparentTag(root as t.NodePath)) {
+ root = findParentTag(root as t.NodePath) || program;
+ }
+
+ root = findParentTag(root as t.NodePath) || program;
+ }
+
if (root.node) {
const roots = lifecycleRootsForProgram.get(program)!;
let extra = root.node.extra;
@@ -182,3 +196,19 @@ function buildNestedLifecycle(tag: t.NodePath): t.Statement[] {
return result;
}
+
+function isAttributeTagLike(tag: t.NodePath) {
+ if (isAttributeTag(tag)) {
+ return true;
+ }
+
+ if (isTransparentTag(tag)) {
+ for (const child of tag.get("body").get("body")) {
+ if (child.isMarkoTag() && isAttributeTagLike(child)) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}