From 0236101bdda6b2930ba347c21676f9c8f48ac8ab Mon Sep 17 00:00:00 2001 From: Yuichiro Yamashita Date: Sun, 14 Aug 2022 12:54:10 +0900 Subject: [PATCH] remove duplicated boolean_attributes --- .../render_dom/wrappers/Element/Attribute.ts | 33 ++----------------- src/shared/boolean_attributes.ts | 2 ++ 2 files changed, 4 insertions(+), 31 deletions(-) diff --git a/src/compiler/compile/render_dom/wrappers/Element/Attribute.ts b/src/compiler/compile/render_dom/wrappers/Element/Attribute.ts index 2caba05e6f..21a44ab92a 100644 --- a/src/compiler/compile/render_dom/wrappers/Element/Attribute.ts +++ b/src/compiler/compile/render_dom/wrappers/Element/Attribute.ts @@ -9,6 +9,7 @@ import Text from '../../../nodes/Text'; import handle_select_value_binding from './handle_select_value_binding'; import { Identifier, Node } from 'estree'; import { namespaces } from '../../../../utils/namespaces'; +import { boolean_attributes } from '../../../../../shared/boolean_attributes'; const non_textlike_input_types = new Set([ 'button', @@ -255,7 +256,7 @@ export default class AttributeWrapper extends BaseAttributeWrapper { get_value(block) { if (this.node.is_true) { - if (this.metadata && boolean_attribute.has(this.metadata.property_name.toLowerCase())) { + if (this.metadata && boolean_attributes.has(this.metadata.property_name.toLowerCase())) { return x`true`; } return x`""`; @@ -376,36 +377,6 @@ Object.keys(attribute_lookup).forEach(name => { if (!metadata.property_name) metadata.property_name = name; }); -// source: https://html.spec.whatwg.org/multipage/indices.html -const boolean_attribute = new Set([ - 'allowfullscreen', - 'allowpaymentrequest', - 'async', - 'autofocus', - 'autoplay', - 'checked', - 'controls', - 'default', - 'defer', - 'disabled', - 'formnovalidate', - 'hidden', - 'inert', - 'ismap', - 'itemscope', - 'loop', - 'multiple', - 'muted', - 'nomodule', - 'novalidate', - 'open', - 'playsinline', - 'readonly', - 'required', - 'reversed', - 'selected' -]); - function should_cache(attribute: AttributeWrapper) { return attribute.is_src || attribute.node.should_cache(); } diff --git a/src/shared/boolean_attributes.ts b/src/shared/boolean_attributes.ts index 4520a2064e..e29f921e32 100644 --- a/src/shared/boolean_attributes.ts +++ b/src/shared/boolean_attributes.ts @@ -12,7 +12,9 @@ export const boolean_attributes = new Set([ 'disabled', 'formnovalidate', 'hidden', + 'inert', 'ismap', + 'itemscope', 'loop', 'multiple', 'muted',