Support hydrating elements with properties whose getters throw.

pull/13211/head
Lucas Garron 2 years ago
parent 36137e0e93
commit 081b10add1

@ -136,7 +136,12 @@ export function set_xlink_attribute(dom, attribute, value) {
*/
export function set_custom_element_data(node, prop, value) {
if (prop in node) {
var curr_val = node[prop];
try {
var curr_val = node[prop];
} catch {
set_attribute(node, prop, value);
return;
}
var next_val = typeof curr_val === 'boolean' && value === '' ? true : value;
if (typeof curr_val !== 'object' || curr_val !== next_val) {
node[prop] = next_val;

@ -0,0 +1,10 @@
// Note that custom element names must be unique across tests that can be run at the same time. So we use a verbose element name instead of just `<custom-element>`
customElements.define("custom-element-with-settable-only-property", class CustomElement extends HTMLElement {
set prop(n) {
this.value = n;
}
get prop() {
throw new Error("This value is not gettable");
}
});

@ -0,0 +1,5 @@
<script>
import "./custom-element-with-settable-only-property.js"
</script>
<custom-element-with-settable-only-property prop="8"></custom-element-with-settable-only-property>
Loading…
Cancel
Save