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
Component.svelte
<script>
// RELATED GITHUB ISSUE: https://github.com/sveltejs/svelte/issues/7461
let msg = 'Hello there';
import Component from './Component.svelte'
</script>

<!-- BOTH SHOULD BE RED -->
<!-- --style-props isn't works -->
<svelte:component this={Component} {msg} --headingColor="red"></svelte:component>
<!-- --style-props works as intended -->
<Component {msg} --headingColor="red"></Component>

Error compiling component

WebAssembly.instantiateStreaming(): value type opcode @+13
/* App.svelte generated by Svelte v3.51.0 */
import {
SvelteComponent,
check_outros,
construct_svelte_component,
create_component,
destroy_component,
detach,
element,
group_outros,
init,
insert,
mount_component,
safe_not_equal,
set_style,
space,
transition_in,
transition_out
} from "svelte/internal";

import Component from './Component.svelte';

function create_fragment(ctx) {
let switch_instance;
let div;
let t;
let component;
let div_1;
let current;
var switch_value = Component;

function switch_props(ctx) {
return { props: { msg } };
}

if (switch_value) {
result = svelte.compile(source, {
generate: ,
});
/* Add a <style> tag to see the CSS output */
		
			
				
  • {
    • html: Fragment {...}
      • start: 163
      • end: 399
      • type: "Fragment"
      • children: [...] (10)
        • Text {...}
          • start: 161
          • end: 163
          • type: "Text"
          • raw: "\n\n"
          • data: "\n\n"
          }
        • Comment {...}
          • start: 163
          • end: 190
          • type: "Comment"
          • data: " BOTH SHOULD BE RED "
          • ignores: []
          }
        • Text {...}
          • start: 190
          • end: 191
          • type: "Text"
          • raw: "\n"
          • data: "\n"
          }
        • Comment {...}
          • start: 191
          • end: 225
          • type: "Comment"
          • data: " --style-props isn't works "
          • ignores: []
          }
        • Text {...}
          • start: 225
          • end: 226
          • type: "Text"
          • raw: "\n"
          • data: "\n"
          }
        • InlineComponent {...}
          • start: 226
          • end: 307
          • type: "InlineComponent"
          • name: "svelte:component"
          • attributes: [...] (2)
            • Attribute {...}
              • start: 261
              • end: 266
              • type: "Attribute"
              • name: "msg"
              • value: [...] (1)
                • AttributeShorthand {...}
                  • start: 262
                  • end: 265
                  • type: "AttributeShorthand"
                  • expression: Identifier {...}
                    • start: 262
                    • end: 265
                    • type: "Identifier"
                    • name: "msg"
                    }
                  }
                ]
              }
            • Attribute {...}
              • start: 267
              • end: 287
              • type: "Attribute"
              • name: "--headingColor"
              • value: [...] (1)
                • Text {...}
                  • start: 283
                  • end: 286
                  • type: "Text"
                  • raw: "red"
                  • data: "red"
                  }
                ]
              }
            ]
          • children: []
          • expression: Identifier {...}
            • type: "Identifier"
            • start: 250
            • end: 259
            • loc: {...}
              • start: {...}
                • line: 9
                • column: 24
                }
              • end: {...}
                • line: 9
                • column: 33
                }
              }
            • name: "Component"
            }
          }
        • Text {...}
          • start: 307
          • end: 308
          • type: "Text"
          • raw: "\n"
          • data: "\n"
          }
        • Comment {...}
          • start: 308
          • end: 348
          • type: "Comment"
          • data: " --style-props works as intended "
          • ignores: []
          }
        • Text {...}
          • start: 348
          • end: 349
          • type: "Text"
          • raw: "\n"
          • data: "\n"
          }
        • InlineComponent {...}
          • start: 349
          • end: 399
          • type: "InlineComponent"
          • name: "Component"
          • attributes: [...] (2)
            • Attribute {...}
              • start: 360
              • end: 365
              • type: "Attribute"
              • name: "msg"
              • value: [...] (1)
                • AttributeShorthand {...}
                  • start: 361
                  • end: 364
                  • type: "AttributeShorthand"
                  • expression: Identifier {...}
                    • start: 361
                    • end: 364
                    • type: "Identifier"
                    • name: "msg"
                    }
                  }
                ]
              }
            • Attribute {...}
              • start: 366
              • end: 386
              • type: "Attribute"
              • name: "--headingColor"
              • value: [...] (1)
                • Text {...}
                  • start: 382
                  • end: 385
                  • type: "Text"
                  • raw: "red"
                  • data: "red"
                  }
                ]
              }
            ]
          • children: []
          }
        ]
      }
    • css: undefined
    • instance: Script {...}
      • type: "Script"
      • start: 0
      • end: 161
      • context: "default"
      • content: Program {...}
        • type: "Program"
        • start: 8
        • end: 152
        • loc: {...}
          • start: {...}
            • line: 1
            • column: 0
            }
          • end: {...}
            • line: 5
            • column: 0
            }
          }
        • body: [...] (2)
          • VariableDeclaration {...}
            • type: "VariableDeclaration"
            • start: 83
            • end: 107
            • loc: {...}
              • start: {...}
                • line: 3
                • column: 1
                }
              • end: {...}
                • line: 3
                • column: 25
                }
              }
            • declarations: [...] (1)
              • VariableDeclarator {...}
                • type: "VariableDeclarator"
                • start: 87
                • end: 106
                • loc: {...}
                  • start: {...}
                    • line: 3
                    • column: 5
                    }
                  • end: {...}
                    • line: 3
                    • column: 24
                    }
                  }
                • id: Identifier {...}
                  • type: "Identifier"
                  • start: 87
                  • end: 90
                  • loc: {...}
                    • start: {...}
                      • line: 3
                      • column: 5
                      }
                    • end: {...}
                      • line: 3
                      • column: 8
                      }
                    }
                  • name: "msg"
                  }
                • init: Literal {...}
                  • type: "Literal"
                  • start: 93
                  • end: 106
                  • loc: {...}
                    • start: {...}
                      • line: 3
                      • column: 11
                      }
                    • end: {...}
                      • line: 3
                      • column: 24
                      }
                    }
                  • value: "Hello there"
                  • raw: "'Hello there'"
                  }
                }
              ]
            • kind: "let"
            • leadingComments: [...] (1)
              • Line {...}
                • type: "Line"
                • value: " RELATED GITHUB ISSUE: https://github.com/sveltejs/svelte/issues/7461"
                • start: 10
                • end: 81
                • has_trailing_newline: true
                }
              ]
            }
          • ImportDeclaration {...}
            • type: "ImportDeclaration"
            • start: 109
            • end: 151
            • loc: {...}
              • start: {...}
                • line: 4
                • column: 1
                }
              • end: {...}
                • line: 4
                • column: 43
                }
              }
            • specifiers: [...] (1)
              • ImportDefaultSpecifier {...}
                • type: "ImportDefaultSpecifier"
                • start: 116
                • end: 125
                • loc: {...}
                  • start: {...}
                    • line: 4
                    • column: 8
                    }
                  • end: {...}
                    • line: 4
                    • column: 17
                    }
                  }
                • local: Identifier {...}
                  • type: "Identifier"
                  • start: 116
                  • end: 125
                  • loc: {...}
                    • start: {...}
                      • line: 4
                      • column: 8
                      }
                    • end: {...}
                      • line: 4
                      • column: 17
                      }
                    }
                  • name: "Component"
                  }
                }
              ]
            • source: Literal {...}
              • type: "Literal"
              • start: 131
              • end: 151
              • loc: {...}
                • start: {...}
                  • line: 4
                  • column: 23
                  }
                • end: {...}
                  • line: 4
                  • column: 43
                  }
                }
              • value: "./Component.svelte"
              • raw: "'./Component.svelte'"
              }
            }
          ]
        • sourceType: "module"
        }
      }
    • module: undefined
    }
The AST is not public API and may change at any point in time