pull/14369/head
Dominic Gannaway 2 years ago
parent dd305582b9
commit b8eb68fc03

@ -6,7 +6,7 @@
import { escape_html } from '../../../../../escaping.js'; import { escape_html } from '../../../../../escaping.js';
import { import {
is_boolean_attribute, is_boolean_attribute,
get_dom_property, is_dom_property,
is_load_error_element, is_load_error_element,
is_void is_void
} from '../../../../../utils.js'; } from '../../../../../utils.js';
@ -557,11 +557,8 @@ function build_element_attribute_update_assignment(element, node_id, attribute,
update = b.stmt(b.call('$.set_value', node_id, value)); update = b.stmt(b.call('$.set_value', node_id, value));
} else if (name === 'checked') { } else if (name === 'checked') {
update = b.stmt(b.call('$.set_checked', node_id, value)); update = b.stmt(b.call('$.set_checked', node_id, value));
} else { } else if (is_dom_property(name)) {
const dom_property = get_dom_property(name); update = b.stmt(b.assignment('=', b.member(node_id, name), value));
if (dom_property) {
update = b.stmt(b.assignment('=', b.member(node_id, dom_property), value));
} else { } else {
if (name === 'style' && attribute.metadata.expression.has_state && has_call) { if (name === 'style' && attribute.metadata.expression.has_state && has_call) {
// ensure we're not creating a separate template effect for this so that // ensure we're not creating a separate template effect for this so that
@ -582,7 +579,6 @@ function build_element_attribute_update_assignment(element, node_id, attribute,
) )
); );
} }
}
if (attribute.metadata.expression.has_state) { if (attribute.metadata.expression.has_state) {
if (has_call) { if (has_call) {

@ -192,7 +192,8 @@ const ATTRIBUTE_ALIASES = {
ismap: 'isMap', ismap: 'isMap',
nomodule: 'noModule', nomodule: 'noModule',
playsinline: 'playsInline', playsinline: 'playsInline',
readonly: 'readOnly' readonly: 'readOnly',
srcobject: 'srcObject'
}; };
/** /**
@ -216,20 +217,11 @@ const DOM_PROPERTIES = [
'srcObject' 'srcObject'
]; ];
/** @type {Map<string, string>} */
let DOM_PROPERTIES_MAP;
/** /**
* @param {string} name * @param {string} name
* @returns {string | undefined}
*/ */
export function get_dom_property(name) { export function is_dom_property(name) {
if (!DOM_PROPERTIES_MAP) { return DOM_PROPERTIES.includes(name);
DOM_PROPERTIES_MAP = new Map(
DOM_PROPERTIES.map((property) => [property.toLowerCase(), property])
);
}
return DOM_PROPERTIES_MAP.get(name);
} }
/** /**

Loading…
Cancel
Save