|
6 | 6 | import { escape_html } from '../../../../../escaping.js'; |
7 | 7 | import { |
8 | 8 | is_boolean_attribute, |
9 | | - DOM_PROPERTIES_MAP, |
| 9 | + get_dom_property, |
10 | 10 | is_load_error_element, |
11 | 11 | is_void |
12 | 12 | } from '../../../../../utils.js'; |
@@ -557,27 +557,31 @@ function build_element_attribute_update_assignment(element, node_id, attribute, |
557 | 557 | update = b.stmt(b.call('$.set_value', node_id, value)); |
558 | 558 | } else if (name === 'checked') { |
559 | 559 | update = b.stmt(b.call('$.set_checked', node_id, value)); |
560 | | - } else if (DOM_PROPERTIES_MAP.has(name)) { |
561 | | - update = b.stmt(b.assignment('=', b.member(node_id, DOM_PROPERTIES_MAP.get(name)), value)); |
562 | 560 | } else { |
563 | | - if (name === 'style' && attribute.metadata.expression.has_state && has_call) { |
564 | | - // ensure we're not creating a separate template effect for this so that |
565 | | - // potential style directives are added to the same effect and therefore always apply |
566 | | - const id = b.id(state.scope.generate('style_derived')); |
567 | | - state.init.push(b.const(id, create_derived(state, b.thunk(value)))); |
568 | | - value = b.call('$.get', id); |
569 | | - has_call = false; |
| 561 | + const dom_property = get_dom_property(name); |
| 562 | + |
| 563 | + if (dom_property) { |
| 564 | + update = b.stmt(b.assignment('=', b.member(node_id, dom_property), value)); |
| 565 | + } else { |
| 566 | + if (name === 'style' && attribute.metadata.expression.has_state && has_call) { |
| 567 | + // ensure we're not creating a separate template effect for this so that |
| 568 | + // potential style directives are added to the same effect and therefore always apply |
| 569 | + const id = b.id(state.scope.generate('style_derived')); |
| 570 | + state.init.push(b.const(id, create_derived(state, b.thunk(value)))); |
| 571 | + value = b.call('$.get', id); |
| 572 | + has_call = false; |
| 573 | + } |
| 574 | + const callee = name.startsWith('xlink') ? '$.set_xlink_attribute' : '$.set_attribute'; |
| 575 | + update = b.stmt( |
| 576 | + b.call( |
| 577 | + callee, |
| 578 | + node_id, |
| 579 | + b.literal(name), |
| 580 | + value, |
| 581 | + is_ignored(element, 'hydration_attribute_changed') && b.true |
| 582 | + ) |
| 583 | + ); |
570 | 584 | } |
571 | | - const callee = name.startsWith('xlink') ? '$.set_xlink_attribute' : '$.set_attribute'; |
572 | | - update = b.stmt( |
573 | | - b.call( |
574 | | - callee, |
575 | | - node_id, |
576 | | - b.literal(name), |
577 | | - value, |
578 | | - is_ignored(element, 'hydration_attribute_changed') && b.true |
579 | | - ) |
580 | | - ); |
581 | 585 | } |
582 | 586 |
|
583 | 587 | if (attribute.metadata.expression.has_state) { |
|
0 commit comments