[WIP] Unified attributes and bindings #380
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A realisation I've been gradually having: it makes sense to treat binding values (i.e. the
foo
inbind:value='foo'
orbind:foo
) the same way expressions are treated (i.e.{{foo}}
). Doing so opens the door to a few things:<Widget :foo />
as shorthand for<Widget foo='{{foo}}'/>
, as mentioned in Add spread for attributes #280 (comment)bind:value='options[key].value
as discussed in this SO question (this is not a statement of intent at this stage, however)generator.contextualise
generator.contextualise
will make sourcemap support much betterTechnically this is a breaking change as it changes the AST format, but I think we can get away with it — I haven't heard of anyone using
svelte.parse
outside the context ofsvelte.compile
. (I'll eat my words later if I have to.)I've only done the first part so far — updating the parser and fixing all the tests broken by doing so. Next step is to refactor the binding code so that it uses
generator.contextualise
.