Skip to content

Commit 90a98e7

Browse files
committed
don't treat attributes and text nodes differently
1 parent d037245 commit 90a98e7

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

packages/svelte/src/compiler/phases/2-analyze/visitors/Identifier.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,11 @@ export function Identifier(node, context) {
126126
}
127127
}
128128

129-
if (!can_inline && context.state.expression) {
130-
context.state.expression.can_inline = false;
131-
}
129+
if (!can_inline) {
130+
if (context.state.expression) {
131+
context.state.expression.can_inline = false;
132+
}
132133

133-
/**
134-
* if the identifier is part of an expression tag of an attribute we want to check if it's inlinable
135-
* before marking the subtree as dynamic. This is because if it's inlinable it will be inlined in the template
136-
* directly making the whole thing actually static.
137-
*/
138-
if (!can_inline || !context.path.find((node) => node.type === 'Attribute')) {
139134
mark_subtree_dynamic(context.path);
140135
}
141136
}

packages/svelte/tests/snapshot/samples/inline-module-vars/_expected/client/index.svelte.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var root = $.template(`<picture><source srcset="${__DECLARED_ASSET_0__}" type="i
1111

1212
export default function Inline_module_vars($$anchor) {
1313
var fragment = root();
14-
var p = $.sibling($.first_child(fragment), 2);
1514

15+
$.next(2);
1616
$.append($$anchor, fragment);
1717
}

0 commit comments

Comments
 (0)