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 checked = false;
function updateChecked() {
checked = true;
}
</script>

<input type="checkbox" bind:checked />

resolving svelte/internal/client
import 'svelte/internal/disclose-version';
import 'svelte/internal/flags/legacy';
import * as $ from 'svelte/internal/client';

var root = $.template(`<input type="checkbox">`);

export default function App($$anchor) {
let checked = $.mutable_state(false);

function updateChecked() {
$.set(checked, true);
}

var input = root();

$.remove_input_defaults(input);
$.bind_checked(input, () => $.get(checked), ($$value) => $.set(checked, $$value));
$.append($$anchor, input);
}
result = svelte.compile(source, {
generate: ,
});
/* Add a <style> tag to see the CSS output */
		
			
				
  • Root {
    • css: null
    • js: []
    • start: 91
    • end: 129
    • type: "Root"
    • fragment: Fragment {...}
      • type: "Fragment"
      • nodes: [...] (2)
        • Text {...}
          • type: "Text"
          • start: 89
          • end: 91
          • raw: "\n\n"
          • data: "\n\n"
          }
        • RegularElement {...}
          • type: "RegularElement"
          • start: 91
          • end: 129
          • name: "input"
          • attributes: [...] (2)
            • Attribute {...}
              • type: "Attribute"
              • start: 98
              • end: 113
              • name: "type"
              • value: [...] (1)
                • Text {...}
                  • start: 104
                  • end: 112
                  • type: "Text"
                  • raw: "checkbox"
                  • data: "checkbox"
                  }
                ]
              }
            • BindDirective {...}
              • start: 114
              • end: 126
              • type: "BindDirective"
              • name: "checked"
              • expression: Identifier {...}
                • start: 119
                • end: 126
                • type: "Identifier"
                • name: "checked"
                }
              • modifiers: []
              }
            ]
          • fragment: Fragment {...}
            • type: "Fragment"
            • nodes: []
            }
          }
        ]
      }
    • options: null
    • instance: Script {...}
      • type: "Script"
      • start: 0
      • end: 89
      • context: "default"
      • content: Program {...}
        • type: "Program"
        • start: 8
        • end: 80
        • loc: {...}
          • start: {...}
            • line: 1
            • column: 0
            }
          • end: {...}
            • line: 6
            • column: 0
            }
          }
        • body: [...] (2)
          • VariableDeclaration {...}
            • type: "VariableDeclaration"
            • start: 10
            • end: 30
            • loc: {...}
              • start: {...}
                • line: 2
                • column: 1
                }
              • end: {...}
                • line: 2
                • column: 21
                }
              }
            • declarations: [...] (1)
              • VariableDeclarator {...}
                • type: "VariableDeclarator"
                • start: 14
                • end: 29
                • loc: {...}
                  • start: {...}
                    • line: 2
                    • column: 5
                    }
                  • end: {...}
                    • line: 2
                    • column: 20
                    }
                  }
                • id: Identifier {...}
                  • type: "Identifier"
                  • start: 14
                  • end: 21
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 5
                      }
                    • end: {...}
                      • line: 2
                      • column: 12
                      }
                    }
                  • name: "checked"
                  }
                • init: Literal {...}
                  • type: "Literal"
                  • start: 24
                  • end: 29
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 15
                      }
                    • end: {...}
                      • line: 2
                      • column: 20
                      }
                    }
                  • value: false
                  • raw: "false"
                  }
                }
              ]
            • kind: "let"
            }
          • FunctionDeclaration {...}
            • type: "FunctionDeclaration"
            • start: 32
            • end: 79
            • loc: {...}
              • start: {...}
                • line: 3
                • column: 1
                }
              • end: {...}
                • line: 5
                • column: 2
                }
              }
            • id: Identifier {...}
              • type: "Identifier"
              • start: 41
              • end: 54
              • loc: {...}
                • start: {...}
                  • line: 3
                  • column: 10
                  }
                • end: {...}
                  • line: 3
                  • column: 23
                  }
                }
              • name: "updateChecked"
              }
            • expression: false
            • generator: false
            • async: false
            • params: []
            • body: BlockStatement {...}
              • type: "BlockStatement"
              • start: 57
              • end: 79
              • loc: {...}
                • start: {...}
                  • line: 3
                  • column: 26
                  }
                • end: {...}
                  • line: 5
                  • column: 2
                  }
                }
              • body: [...] (1)
                • ExpressionStatement {...}
                  • type: "ExpressionStatement"
                  • start: 61
                  • end: 76
                  • loc: {...}
                    • start: {...}
                      • line: 4
                      • column: 2
                      }
                    • end: {...}
                      • line: 4
                      • column: 17
                      }
                    }
                  • expression: AssignmentExpression {...}
                    • type: "AssignmentExpression"
                    • start: 61
                    • end: 75
                    • loc: {...}
                      • start: {...}
                        • line: 4
                        • column: 2
                        }
                      • end: {...}
                        • line: 4
                        • column: 16
                        }
                      }
                    • operator: "="
                    • left: Identifier {...}
                      • type: "Identifier"
                      • start: 61
                      • end: 68
                      • loc: {...}
                        • start: {...}
                          • line: 4
                          • column: 2
                          }
                        • end: {...}
                          • line: 4
                          • column: 9
                          }
                        }
                      • name: "checked"
                      }
                    • right: Literal {...}
                      • type: "Literal"
                      • start: 71
                      • end: 75
                      • loc: {...}
                        • start: {...}
                          • line: 4
                          • column: 12
                          }
                        • end: {...}
                          • line: 4
                          • column: 16
                          }
                        }
                      • value: true
                      • raw: "true"
                      }
                    }
                  }
                ]
              }
            }
          ]
        • sourceType: "module"
        }
      • attributes: []
      }
    }
The AST is not public API and may change at any point in time
Compile Svelte in your Head - bind: • Playground • Svelte