mirror of https://github.com/sveltejs/svelte
parent
32a1453805
commit
6c60287069
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: no inlining for conditionals inside legacy template expressions
|
@ -0,0 +1,17 @@
|
|||||||
|
/** @import { ConditionalExpression } from 'estree' */
|
||||||
|
/** @import { Context } from '../types' */
|
||||||
|
|
||||||
|
import { mark_subtree_dynamic } from './shared/fragment';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ConditionalExpression} node
|
||||||
|
* @param {Context} context
|
||||||
|
*/
|
||||||
|
export function ConditionalExpression(node, context) {
|
||||||
|
// In legacy mode, we treat conditionals inside the template as not inlinable so patterns
|
||||||
|
// such as BROWSER ? foo : bar, continue to work during hydration
|
||||||
|
if (context.state.expression && !context.state.analysis.runes) {
|
||||||
|
context.state.expression.can_inline = false;
|
||||||
|
mark_subtree_dynamic(context.path);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
html: `<div title="client">div</div>`
|
||||||
|
});
|
@ -0,0 +1,5 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
const browser = typeof window !== 'undefined';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div title={browser ? "client": "server"}>div</div>
|
Loading…
Reference in new issue