File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
packages/svelte/src/compiler/phases/3-transform/server/visitors Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -14,13 +14,16 @@ import { build_template } from './shared/utils.js';
14
14
*/
15
15
export function SvelteElement ( node , context ) {
16
16
let tag = /** @type {Expression } */ ( context . visit ( node . tag ) ) ;
17
- if ( tag . type !== 'Identifier' ) {
18
- const tag_id = context . state . scope . generate ( '$$tag' ) ;
19
- context . state . init . push ( b . const ( tag_id , tag ) ) ;
20
- tag = b . id ( tag_id ) ;
21
- }
22
17
23
18
if ( dev ) {
19
+ // Ensure getters/function calls aren't called multiple times.
20
+ // If we ever start referencing `tag` more than once in prod, move this out of the if block.
21
+ if ( tag . type !== 'Identifier' ) {
22
+ const tag_id = context . state . scope . generate ( '$$tag' ) ;
23
+ context . state . init . push ( b . const ( tag_id , tag ) ) ;
24
+ tag = b . id ( tag_id ) ;
25
+ }
26
+
24
27
if ( node . fragment . nodes . length > 0 ) {
25
28
context . state . init . push ( b . stmt ( b . call ( '$.validate_void_dynamic_element' , b . thunk ( tag ) ) ) ) ;
26
29
}
You can’t perform that action at this time.
0 commit comments