fixes#14439
This bug was introduced in #13642 because setting the input to null means the equality check ("is the input different") fails if you set the value to null
Also fixes#14441 - this bug was present for a long time, and the reason is the same as for the other bug: The equality check always returns "yes this is the same" if the value is undefined initially. The fix is similar; we need to initialize the input to something that can never be equal to whatever value is passed
This reverts #13255 / #13158, and helps with the validation error part of #14120
If you would have a component like this...
```svelte
<td>hi there</td>
```
...and then render it on the server via our `render` function like this:
```js
const result = render(Main);
```
...then right now you get an error saying that `td` is not valid at this position. But that doesn't seem right, because we should give people the benefit of the doubt: It may very well be that someone renders such a component and then correctly puts it into a `tr` tag themselves on the server (another example is rendering a full html document like in #14120).
All the other validation where there's a known parent (X not valid inside Y) is untouched by this.
Doing this as cleanup prior to tackling #13331
* chore: remove references to node.parent
* types
* add ElementWithPath interface
* put path on analysis.elements instead of metadata
* Revert "put path on analysis.elements instead of metadata"
This reverts commit c0c7ab8bd1.
* use node.metadata.path
* remove a node.parent usage
* another
* and another, albeit by replacing some bewildering code with some more bewildering code
* make loop idiomatic
* replace some more weirdo code
* simplify
* fix: always use set for private identifiers
* we can simplify this further - no need to check the value was transformed, since the outcome of not returning immediately is the same but with extra steps
* add explanatory note
---------
Co-authored-by: Rich Harris <rich.harris@vercel.com>
through #14363 I noticed our `export default` validation wasn't quite right:
- missed checking for derived/state exports
- the "cannot have a default export" error was only thrown if you did `export default` from the instance script, but it shouldn't matter from which component part you export it; it's never ok
* fix: ensure internal cloning can work circular values
* better fixc
* 'original' feels slightly clearer than 'json_instance'
* use an optional parameter, so we can omit it in most cases
* Update packages/svelte/src/internal/shared/clone.js
Co-authored-by: Rich Harris <rich.harris@vercel.com>
---------
Co-authored-by: Rich Harris <rich.harris@vercel.com>
The detection whether or not props are writable is buggy; it doesn't take into account the case when instantiating components via `mount` or legacy-`new`
Fixes#14161
This posed an interesting question: What to do about (non-)`bind:`able properties? The answer I arrived on was: Treat it as if everything that _can_ be bound _is_ treated as bound, and everything else as readonly. In other words, if you're reassigning a prop, it will diverge from the passed in props if it's not bindable or not set in the parent, otherwise it will mutate the passed in props. I think that makes the most sense, given that you can't control this behavior from the outside.
* fix: avoid marking subtree as dynamic for inlined attributes
* fix: i'm a silly goose 🪿
* chore: refactor `is_inlinable_expression` to accept the attribute
* feat: inline dom expression too
* fix: special case literals with `"` in it and fix standalone case
* chore: simpler check first
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
* typo
* add more stuff to snapshot test
* simplify/speedup by doing the work once, during analysis
* simplify
* simplify - no reason these cases should prevent inlining
* return template
* name is incorrect
* name is incorrect
* fix escaping
* no longer necessary
* remove obsolete description
* better concatenation
* fix test
* do the work at runtime
* fix another thing
* tidy
* tidy up
* simplify
* simplify
* fix
* note to self
* another
* simplify
* more accurate name
* simplify
* simplify
* explain what is happening
* tidy up
* simplify
* better inlining
* update test
* colocate some code
* better inlining
* use attribute metadata
* Update packages/svelte/src/compiler/phases/2-analyze/visitors/Identifier.js
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
* Apply suggestions from code review
---------
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
Co-authored-by: Rich Harris <rich.harris@vercel.com>