Handle read-only properties on DOM nodes

There might be cases where there are properties that are read-only and
setting their value would trigger an exception. Address that by querying
the descriptor and figuring out if the property is writable.
pull/8340/head
Indranil 4 years ago
parent d4363510fc
commit af61aa9ac9

@ -325,7 +325,8 @@ export function set_custom_element_data_map(node, data_map: Record<string, unkno
} }
export function set_custom_element_data(node, prop, value) { export function set_custom_element_data(node, prop, value) {
if (prop in node) { const descriptor = Object.getOwnPropertyDescriptor(node, prop);
if (descriptor && descriptor.writable) {
node[prop] = typeof node[prop] === 'boolean' && value === '' ? true : value; node[prop] = typeof node[prop] === 'boolean' && value === '' ? true : value;
} else { } else {
attr(node, prop, value); attr(node, prop, value);

Loading…
Cancel
Save