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>
export let condition;
</script>

<div>
{#if condition}
<div />
{/if}
</div>

loading Svelte compiler...
import 'svelte/internal/disclose-version';
import 'svelte/internal/flags/legacy';
import * as $ from 'svelte/internal/client';

var root_1 = $.template(`<div></div>`);
var root = $.template(`<div><!></div>`);

export default function App($$anchor, $$props) {
let condition = $.prop($$props, 'condition', 8);
var div = root();
var node = $.child(div);

{
var consequent = ($$anchor) => {
var div_1 = root_1();

$.append($$anchor, div_1);
};

$.if(node, ($$render) => {
if (condition()) $$render(consequent);
});
}

$.reset(div);
$.append($$anchor, div);
}
result = svelte.compile(source, {
generate: ,
});
/* Add a <style> tag to see the CSS output */
		
			
				
  • Root {
    • css: null
    • js: []
    • start: 43
    • end: 89
    • type: "Root"
    • fragment: Fragment {...}
      • type: "Fragment"
      • nodes: [...] (2)
        • Text {...}
          • type: "Text"
          • start: 41
          • end: 43
          • raw: "\n\n"
          • data: "\n\n"
          }
        • RegularElement {...}
          • type: "RegularElement"
          • start: 43
          • end: 89
          • name: "div"
          • attributes: []
          • fragment: Fragment {...}
            • type: "Fragment"
            • nodes: [...] (3)
              • Text {...}
                • type: "Text"
                • start: 48
                • end: 50
                • raw: "\n\t"
                • data: "\n\t"
                }
              • IfBlock {...}
                • type: "IfBlock"
                • elseif: false
                • start: 50
                • end: 82
                • test: Identifier {...}
                  • type: "Identifier"
                  • start: 55
                  • end: 64
                  • loc: {...}
                    • start: {...}
                      • line: 6
                      • column: 6
                      }
                    • end: {...}
                      • line: 6
                      • column: 15
                      }
                    }
                  • name: "condition"
                  }
                • consequent: Fragment {...}
                  • type: "Fragment"
                  • nodes: [...] (3)
                    • Text {...}
                      • type: "Text"
                      • start: 65
                      • end: 68
                      • raw: "\n\t\t"
                      • data: "\n\t\t"
                      }
                    • RegularElement {...}
                      • type: "RegularElement"
                      • start: 68
                      • end: 75
                      • name: "div"
                      • attributes: []
                      • fragment: Fragment {...}
                        • type: "Fragment"
                        • nodes: []
                        }
                      }
                    • Text {...}
                      • type: "Text"
                      • start: 75
                      • end: 77
                      • raw: "\n\t"
                      • data: "\n\t"
                      }
                    ]
                  }
                • alternate: null
                }
              • Text {...}
                • type: "Text"
                • start: 82
                • end: 83
                • raw: "\n"
                • data: "\n"
                }
              ]
            }
          }
        ]
      }
    • options: null
    • instance: Script {...}
      • type: "Script"
      • start: 0
      • end: 41
      • context: "default"
      • content: Program {...}
        • type: "Program"
        • start: 8
        • end: 32
        • loc: {...}
          • start: {...}
            • line: 1
            • column: 0
            }
          • end: {...}
            • line: 3
            • column: 0
            }
          }
        • body: [...] (1)
          • ExportNamedDeclaration {...}
            • type: "ExportNamedDeclaration"
            • start: 10
            • end: 31
            • loc: {...}
              • start: {...}
                • line: 2
                • column: 1
                }
              • end: {...}
                • line: 2
                • column: 22
                }
              }
            • declaration: VariableDeclaration {...}
              • type: "VariableDeclaration"
              • start: 17
              • end: 31
              • loc: {...}
                • start: {...}
                  • line: 2
                  • column: 8
                  }
                • end: {...}
                  • line: 2
                  • column: 22
                  }
                }
              • declarations: [...] (1)
                • VariableDeclarator {...}
                  • type: "VariableDeclarator"
                  • start: 21
                  • end: 30
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 12
                      }
                    • end: {...}
                      • line: 2
                      • column: 21
                      }
                    }
                  • id: Identifier {...}
                    • type: "Identifier"
                    • start: 21
                    • end: 30
                    • loc: {...}
                      • start: {...}
                        • line: 2
                        • column: 12
                        }
                      • end: {...}
                        • line: 2
                        • column: 21
                        }
                      }
                    • name: "condition"
                    }
                  • init: null
                  }
                ]
              • kind: "let"
              }
            • specifiers: []
            • source: null
            }
          ]
        • sourceType: "module"
        }
      • attributes: []
      }
    }
The AST is not public API and may change at any point in time
Compile Svelte in your Head - {#if} • Playground • Svelte