Skip to main content
Create new
Introduction
Reactivity
Props
Logic
Events
Bindings
Lifecycle
Stores
Motion
Transitions
Animations
Easing
SVG
Actions
Classes
Component composition
Context API
Special elements
Module context
Debugging
7GUIs
Miscellaneous
App.svelte
<script>
let name = 'world';
let tag = "h1"
</script>

<svelte:element this={tag}>Hello {name}!</svelte:element>

<style>
h1 {
color: red;
}
</style>

Error compiling component

WebAssembly.instantiateStreaming(): value type opcode @+13
/* App.svelte generated by Svelte v3.51.0 */
import {
SvelteComponent,
append_styles,
assign,
detach,
element,
empty,
get_spread_update,
init,
insert,
noop,
safe_not_equal,
set_attributes,
set_custom_element_data_map
} from "svelte/internal";

function add_css(target) {
append_styles(target, "svelte-bt9zrl", "h1.svelte-bt9zrl{color:red}");
}

// (6:0) <svelte:element this={tag}>
function create_dynamic_element(ctx) {
let svelte_element;
let svelte_element_levels = [{ class: "svelte-bt9zrl" }];
let svelte_element_data = {};

for (let i = 0; i < svelte_element_levels.length; i += 1) {
svelte_element_data = assign(svelte_element_data, svelte_element_levels[i]);
}

return {
c() {
svelte_element = element(tag);
svelte_element.textContent = `Hello ${name}!`;

result = svelte.compile(source, {
generate: ,
});
h1.svelte-bt9zrl{color:red}
		
			
				
  • {
    • html: Fragment {...}
      • start: 57
      • end: 114
      • type: "Fragment"
      • children: [...] (3)
        • Text {...}
          • start: 55
          • end: 57
          • type: "Text"
          • raw: "\n\n"
          • data: "\n\n"
          }
        • Element {...}
          • start: 57
          • end: 114
          • type: "Element"
          • name: "svelte:element"
          • attributes: []
          • children: [...] (3)
            • Text {...}
              • start: 84
              • end: 90
              • type: "Text"
              • raw: "Hello "
              • data: "Hello "
              }
            • MustacheTag {...}
              • start: 90
              • end: 96
              • type: "MustacheTag"
              • expression: Identifier {...}
                • type: "Identifier"
                • start: 91
                • end: 95
                • loc: {...}
                  • start: {...}
                    • line: 6
                    • column: 34
                    }
                  • end: {...}
                    • line: 6
                    • column: 38
                    }
                  }
                • name: "name"
                }
              }
            • Text {...}
              • start: 96
              • end: 97
              • type: "Text"
              • raw: "!"
              • data: "!"
              }
            ]
          • tag: Identifier {...}
            • type: "Identifier"
            • start: 79
            • end: 82
            • loc: {...}
              • start: {...}
                • line: 6
                • column: 22
                }
              • end: {...}
                • line: 6
                • column: 25
                }
              }
            • name: "tag"
            }
          }
        • Text {...}
          • start: 114
          • end: 116
          • type: "Text"
          • raw: "\n\n"
          • data: "\n\n"
          }
        ]
      }
    • css: Style {...}
      • type: "Style"
      • start: 116
      • end: 155
      • attributes: []
      • children: [...] (1)
        • Rule {...}
          • type: "Rule"
          • prelude: SelectorList {...}
            • type: "SelectorList"
            • children: [...] (1)
              • Selector {...}
                • type: "Selector"
                • children: [...] (1)
                  • TypeSelector {...}
                    • type: "TypeSelector"
                    • name: "h1"
                    • start: 125
                    • end: 127
                    }
                  ]
                • start: 125
                • end: 127
                }
              ]
            • start: 125
            • end: 127
            }
          • block: Block {...}
            • type: "Block"
            • children: [...] (1)
              • Declaration {...}
                • type: "Declaration"
                • important: false
                • property: "color"
                • value: Value {...}
                  • type: "Value"
                  • children: [...] (1)
                    • Identifier {...}
                      • type: "Identifier"
                      • name: "red"
                      • start: 139
                      • end: 142
                      }
                    ]
                  • start: 139
                  • end: 142
                  }
                • start: 132
                • end: 142
                }
              ]
            • start: 128
            • end: 146
            }
          • start: 125
          • end: 146
          }
        ]
      • content: {...}
        • start: 123
        • end: 147
        • styles: "\n\th1 {\n\t\tcolor: red;\n\t}\n"
        }
      }
    • instance: Script {...}
      • type: "Script"
      • start: 0
      • end: 55
      • context: "default"
      • content: Program {...}
        • type: "Program"
        • start: 8
        • end: 46
        • loc: {...}
          • start: {...}
            • line: 1
            • column: 0
            }
          • end: {...}
            • line: 4
            • column: 0
            }
          }
        • body: [...] (2)
          • VariableDeclaration {...}
            • type: "VariableDeclaration"
            • start: 10
            • end: 29
            • loc: {...}
              • start: {...}
                • line: 2
                • column: 1
                }
              • end: {...}
                • line: 2
                • column: 20
                }
              }
            • declarations: [...] (1)
              • VariableDeclarator {...}
                • type: "VariableDeclarator"
                • start: 14
                • end: 28
                • loc: {...}
                  • start: {...}
                    • line: 2
                    • column: 5
                    }
                  • end: {...}
                    • line: 2
                    • column: 19
                    }
                  }
                • id: Identifier {...}
                  • type: "Identifier"
                  • start: 14
                  • end: 18
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 5
                      }
                    • end: {...}
                      • line: 2
                      • column: 9
                      }
                    }
                  • name: "name"
                  }
                • init: Literal {...}
                  • type: "Literal"
                  • start: 21
                  • end: 28
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 12
                      }
                    • end: {...}
                      • line: 2
                      • column: 19
                      }
                    }
                  • value: "world"
                  • raw: "'world'"
                  }
                }
              ]
            • kind: "let"
            }
          • VariableDeclaration {...}
            • type: "VariableDeclaration"
            • start: 31
            • end: 45
            • loc: {...}
              • start: {...}
                • line: 3
                • column: 1
                }
              • end: {...}
                • line: 3
                • column: 15
                }
              }
            • declarations: [...] (1)
              • VariableDeclarator {...}
                • type: "VariableDeclarator"
                • start: 35
                • end: 45
                • loc: {...}
                  • start: {...}
                    • line: 3
                    • column: 5
                    }
                  • end: {...}
                    • line: 3
                    • column: 15
                    }
                  }
                • id: Identifier {...}
                  • type: "Identifier"
                  • start: 35
                  • end: 38
                  • loc: {...}
                    • start: {...}
                      • line: 3
                      • column: 5
                      }
                    • end: {...}
                      • line: 3
                      • column: 8
                      }
                    }
                  • name: "tag"
                  }
                • init: Literal {...}
                  • type: "Literal"
                  • start: 41
                  • end: 45
                  • loc: {...}
                    • start: {...}
                      • line: 3
                      • column: 11
                      }
                    • end: {...}
                      • line: 3
                      • column: 15
                      }
                    }
                  • value: "h1"
                  • raw: "\"h1\""
                  }
                }
              ]
            • kind: "let"
            }
          ]
        • sourceType: "module"
        }
      }
    • module: undefined
    }
The AST is not public API and may change at any point in time