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>
import { marked } from 'marked';
let text = $state(`Some words are *italic*, some are **bold**`);
</script>

<textarea bind:value={text}></textarea>

{@html marked(text)}

<style>
textarea {
width: 100%;
height: 200px;
}
</style>

Error compiling component

WebAssembly.instantiateStreaming(): value type opcode @+13
import 'svelte/internal/disclose-version';
import * as $ from 'svelte/internal/client';
import { marked } from 'marked';

var root = $.template(`<textarea class="svelte-hyxn8s"></textarea> <!>`, 1);

export default function App($$anchor, $$props) {
$.push($$props, true);

let text = $.state(`Some words are *italic*, some are **bold**`);
var fragment = root();
var textarea = $.first_child(fragment);

$.remove_textarea_child(textarea);

var node = $.sibling(textarea, 2);

$.html(node, () => marked($.get(text)), false, false);
$.bind_value(textarea, () => $.get(text), ($$value) => $.set(text, $$value));
$.append($$anchor, fragment);
$.pop();
}
result = svelte.compile(source, {
generate: ,
});

textarea.svelte-hyxn8s {
width: 100%;
height: 200px;
}

		
			
				
  • Root {
    • css: StyleSheet {...}
      • type: "StyleSheet"
      • start: 183
      • end: 246
      • attributes: []
      • children: [...] (1)
        • Rule {...}
          • type: "Rule"
          • prelude: SelectorList {...}
            • type: "SelectorList"
            • start: 192
            • end: 200
            • children: [...] (1)
              • ComplexSelector {...}
                • type: "ComplexSelector"
                • start: 192
                • end: 200
                • children: [...] (1)
                  • RelativeSelector {...}
                    • type: "RelativeSelector"
                    • combinator: null
                    • selectors: [...] (1)
                      • TypeSelector {...}
                        • type: "TypeSelector"
                        • name: "textarea"
                        • start: 192
                        • end: 200
                        }
                      ]
                    • start: 192
                    • end: 200
                    }
                  ]
                }
              ]
            }
          • block: Block {...}
            • type: "Block"
            • start: 201
            • end: 237
            • children: [...] (2)
              • Declaration {...}
                • type: "Declaration"
                • start: 205
                • end: 216
                • property: "width"
                • value: "100%"
                }
              • Declaration {...}
                • type: "Declaration"
                • start: 220
                • end: 233
                • property: "height"
                • value: "200px"
                }
              ]
            }
          • start: 192
          • end: 237
          }
        ]
      • content: {...}
        • start: 190
        • end: 238
        • styles: "\n\ttextarea {\n\t\twidth: 100%;\n\t\theight: 200px;\n\t}\n"
        • comment: null
        }
      }
    • js: []
    • start: 120
    • end: 181
    • type: "Root"
    • fragment: Fragment {...}
      • type: "Fragment"
      • nodes: [...] (5)
        • Text {...}
          • type: "Text"
          • start: 118
          • end: 120
          • raw: "\n\n"
          • data: "\n\n"
          }
        • RegularElement {...}
          • type: "RegularElement"
          • start: 120
          • end: 159
          • name: "textarea"
          • attributes: [...] (2)
            • BindDirective {...}
              • start: 130
              • end: 147
              • type: "BindDirective"
              • name: "value"
              • expression: Identifier {...}
                • type: "Identifier"
                • start: 142
                • end: 146
                • loc: {...}
                  • start: {...}
                    • line: 6
                    • column: 22
                    }
                  • end: {...}
                    • line: 6
                    • column: 26
                    }
                  }
                • name: "text"
                }
              • modifiers: []
              }
            • Attribute {...}
              • type: "Attribute"
              • start: -1
              • end: -1
              • name: "class"
              • value: [...] (1)
                • Text {...}
                  • type: "Text"
                  • data: "svelte-hyxn8s"
                  • raw: "svelte-hyxn8s"
                  • start: -1
                  • end: -1
                  }
                ]
              }
            ]
          • fragment: Fragment {...}
            • type: "Fragment"
            • nodes: []
            }
          }
        • Text {...}
          • type: "Text"
          • start: 159
          • end: 161
          • raw: " "
          • data: " "
          }
        • HtmlTag {...}
          • type: "HtmlTag"
          • start: 161
          • end: 181
          • expression: CallExpression {...}
            • type: "CallExpression"
            • start: 168
            • end: 180
            • loc: {...}
              • start: {...}
                • line: 8
                • column: 7
                }
              • end: {...}
                • line: 8
                • column: 19
                }
              }
            • callee: Identifier {...}
              • type: "Identifier"
              • start: 168
              • end: 174
              • loc: {...}
                • start: {...}
                  • line: 8
                  • column: 7
                  }
                • end: {...}
                  • line: 8
                  • column: 13
                  }
                }
              • name: "marked"
              }
            • arguments: [...] (1)
              • Identifier {...}
                • type: "Identifier"
                • start: 175
                • end: 179
                • loc: {...}
                  • start: {...}
                    • line: 8
                    • column: 14
                    }
                  • end: {...}
                    • line: 8
                    • column: 18
                    }
                  }
                • name: "text"
                }
              ]
            • optional: false
            }
          }
        • Text {...}
          • type: "Text"
          • start: 181
          • end: 183
          • raw: "\n\n"
          • data: "\n\n"
          }
        ]
      }
    • options: null
    • instance: Script {...}
      • type: "Script"
      • start: 0
      • end: 118
      • context: "default"
      • content: Program {...}
        • type: "Program"
        • start: 8
        • end: 109
        • loc: {...}
          • start: {...}
            • line: 1
            • column: 0
            }
          • end: {...}
            • line: 4
            • column: 0
            }
          }
        • body: [...] (2)
          • ImportDeclaration {...}
            • type: "ImportDeclaration"
            • start: 10
            • end: 42
            • loc: {...}
              • start: {...}
                • line: 2
                • column: 1
                }
              • end: {...}
                • line: 2
                • column: 33
                }
              }
            • specifiers: [...] (1)
              • ImportSpecifier {...}
                • type: "ImportSpecifier"
                • start: 19
                • end: 25
                • loc: {...}
                  • start: {...}
                    • line: 2
                    • column: 10
                    }
                  • end: {...}
                    • line: 2
                    • column: 16
                    }
                  }
                • imported: Identifier {...}
                  • type: "Identifier"
                  • start: 19
                  • end: 25
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 10
                      }
                    • end: {...}
                      • line: 2
                      • column: 16
                      }
                    }
                  • name: "marked"
                  }
                • local: Identifier {...}
                  • type: "Identifier"
                  • start: 19
                  • end: 25
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 10
                      }
                    • end: {...}
                      • line: 2
                      • column: 16
                      }
                    }
                  • name: "marked"
                  }
                }
              ]
            • source: Literal {...}
              • type: "Literal"
              • start: 33
              • end: 41
              • loc: {...}
                • start: {...}
                  • line: 2
                  • column: 24
                  }
                • end: {...}
                  • line: 2
                  • column: 32
                  }
                }
              • value: "marked"
              • raw: "'marked'"
              }
            }
          • VariableDeclaration {...}
            • type: "VariableDeclaration"
            • start: 44
            • end: 108
            • loc: {...}
              • start: {...}
                • line: 3
                • column: 1
                }
              • end: {...}
                • line: 3
                • column: 65
                }
              }
            • declarations: [...] (1)
              • VariableDeclarator {...}
                • type: "VariableDeclarator"
                • start: 48
                • end: 107
                • loc: {...}
                  • start: {...}
                    • line: 3
                    • column: 5
                    }
                  • end: {...}
                    • line: 3
                    • column: 64
                    }
                  }
                • id: Identifier {...}
                  • type: "Identifier"
                  • start: 48
                  • end: 52
                  • loc: {...}
                    • start: {...}
                      • line: 3
                      • column: 5
                      }
                    • end: {...}
                      • line: 3
                      • column: 9
                      }
                    }
                  • name: "text"
                  }
                • init: CallExpression {...}
                  • type: "CallExpression"
                  • start: 55
                  • end: 107
                  • loc: {...}
                    • start: {...}
                      • line: 3
                      • column: 12
                      }
                    • end: {...}
                      • line: 3
                      • column: 64
                      }
                    }
                  • callee: Identifier {...}
                    • type: "Identifier"
                    • start: 55
                    • end: 61
                    • loc: {...}
                      • start: {...}
                        • line: 3
                        • column: 12
                        }
                      • end: {...}
                        • line: 3
                        • column: 18
                        }
                      }
                    • name: "$state"
                    }
                  • arguments: [...] (1)
                    • TemplateLiteral {...}
                      • type: "TemplateLiteral"
                      • start: 62
                      • end: 106
                      • loc: {...}
                        • start: {...}
                          • line: 3
                          • column: 19
                          }
                        • end: {...}
                          • line: 3
                          • column: 63
                          }
                        }
                      • expressions: []
                      • quasis: [...] (1)
                        • TemplateElement {...}
                          • type: "TemplateElement"
                          • start: 63
                          • end: 105
                          • loc: {...}
                            • start: {...}
                              • line: 3
                              • column: 20
                              }
                            • end: {...}
                              • line: 3
                              • column: 62
                              }
                            }
                          • value: {...}
                            • raw: "Some words are *italic*, some are **bold**"
                            • cooked: "Some words are *italic*, some are **bold**"
                            }
                          • tail: true
                          }
                        ]
                      }
                    ]
                  • optional: false
                  }
                }
              ]
            • kind: "let"
            }
          ]
        • sourceType: "module"
        }
      • attributes: []
      }
    }
The AST is not public API and may change at any point in time
Textarea inputs • Playground • Svelte