-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: support camelCase properties on custom elements (#9328)
while attributes are case insensitive, properties are not. to not introduce a breaking change, the lowercased variant is checked first. fixes #9325
- Loading branch information
1 parent
6f508a0
commit 9900c85
Showing
7 changed files
with
83 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'svelte': patch | ||
--- | ||
|
||
fix: support camelCase properties on custom elements |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
packages/svelte/test/runtime/samples/attribute-casing-custom-element/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default { | ||
skip_if_ssr: true, | ||
skip_if_hydrate: true, | ||
html: ` | ||
<my-custom-element>Hello World!</my-custom-element> | ||
` | ||
}; |
25 changes: 25 additions & 0 deletions
25
packages/svelte/test/runtime/samples/attribute-casing-custom-element/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<script> | ||
class MyCustomElement extends HTMLElement { | ||
constructor() { | ||
super(); | ||
this._obj = null; | ||
} | ||
set camelCase(obj) { | ||
this._obj = obj; | ||
this.render(); | ||
} | ||
connectedCallback() { | ||
this.render(); | ||
} | ||
render() { | ||
this.innerHTML = 'Hello ' + this._obj.text + '!'; | ||
} | ||
} | ||
window.customElements.define('my-custom-element', MyCustomElement); | ||
</script> | ||
|
||
<my-custom-element camelCase={{ text: 'World' }} /> |
7 changes: 7 additions & 0 deletions
7
packages/svelte/test/runtime/samples/attribute-custom-element-inheritance/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default { | ||
skip_if_ssr: true, | ||
skip_if_hydrate: true, | ||
html: ` | ||
<my-custom-inheritance-element>Hello World!</my-custom-inheritance-element> | ||
` | ||
}; |
33 changes: 33 additions & 0 deletions
33
packages/svelte/test/runtime/samples/attribute-custom-element-inheritance/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<script> | ||
class MyCustomElement extends HTMLElement { | ||
constructor() { | ||
super(); | ||
this._obj = null; | ||
this._text = null; | ||
} | ||
set text(text) { | ||
this._text = text; | ||
this.render(); | ||
} | ||
set camelCase(obj) { | ||
this._obj = obj; | ||
this.render(); | ||
} | ||
connectedCallback() { | ||
this.render(); | ||
} | ||
render() { | ||
this.innerHTML = 'Hello ' + this._obj.text + this._text; | ||
} | ||
} | ||
class Extended extends MyCustomElement {} | ||
window.customElements.define('my-custom-inheritance-element', Extended); | ||
</script> | ||
|
||
<my-custom-inheritance-element camelCase={{ text: 'World' }} text="!" /> |