From 4b53f7c69fb2141df023ed36aab0f27766310818 Mon Sep 17 00:00:00 2001 From: baseballyama Date: Thu, 14 Apr 2022 03:01:16 +0900 Subject: [PATCH] move to shared folder --- src/compiler/compile/nodes/Element.ts | 2 +- src/compiler/compile/render_dom/wrappers/Element/index.ts | 2 +- src/compiler/compile/render_ssr/handlers/Element.ts | 2 +- src/compiler/parse/state/tag.ts | 2 +- src/compiler/utils/names.ts | 6 ------ src/runtime/internal/ssr.ts | 2 +- src/shared/utils/names.ts | 5 +++++ 7 files changed, 10 insertions(+), 11 deletions(-) create mode 100644 src/shared/utils/names.ts diff --git a/src/compiler/compile/nodes/Element.ts b/src/compiler/compile/nodes/Element.ts index 5aff966996..735562d627 100644 --- a/src/compiler/compile/nodes/Element.ts +++ b/src/compiler/compile/nodes/Element.ts @@ -1,4 +1,4 @@ -import { is_void } from '../../utils/names'; +import { is_void } from '../../../shared/utils/names'; import Node from './shared/Node'; import Attribute from './Attribute'; import Binding from './Binding'; diff --git a/src/compiler/compile/render_dom/wrappers/Element/index.ts b/src/compiler/compile/render_dom/wrappers/Element/index.ts index 5145db9fef..1601e73fb8 100644 --- a/src/compiler/compile/render_dom/wrappers/Element/index.ts +++ b/src/compiler/compile/render_dom/wrappers/Element/index.ts @@ -2,7 +2,7 @@ import Renderer from '../../Renderer'; import Element from '../../../nodes/Element'; import Wrapper from '../shared/Wrapper'; import Block from '../../Block'; -import { is_void } from '../../../../utils/names'; +import { is_void } from '../../../../../shared/utils/names'; import FragmentWrapper from '../Fragment'; import { escape_html, string_literal } from '../../../utils/stringify'; import TextWrapper from '../Text'; diff --git a/src/compiler/compile/render_ssr/handlers/Element.ts b/src/compiler/compile/render_ssr/handlers/Element.ts index b369f6eff9..6d73af8cb6 100644 --- a/src/compiler/compile/render_ssr/handlers/Element.ts +++ b/src/compiler/compile/render_ssr/handlers/Element.ts @@ -1,4 +1,4 @@ -import { is_void } from '../../../utils/names'; +import { is_void } from '../../../../shared/utils/names'; import { get_attribute_expression, get_attribute_value, get_class_attribute_value } from './shared/get_attribute_value'; import { boolean_attributes } from './shared/boolean_attributes'; import Renderer, { RenderOptions } from '../Renderer'; diff --git a/src/compiler/parse/state/tag.ts b/src/compiler/parse/state/tag.ts index 46e6e2f83a..efce375b7e 100644 --- a/src/compiler/parse/state/tag.ts +++ b/src/compiler/parse/state/tag.ts @@ -1,7 +1,7 @@ import { Directive, DirectiveType, TemplateNode, Text } from '../../interfaces'; import { extract_svelte_ignore } from '../../utils/extract_svelte_ignore'; import fuzzymatch from '../../utils/fuzzymatch'; -import { is_void } from '../../utils/names'; +import { is_void } from '../../../shared/utils/names'; import parser_errors from '../errors'; import { Parser } from '../index'; import read_expression from '../read/expression'; diff --git a/src/compiler/utils/names.ts b/src/compiler/utils/names.ts index b701d7c025..e091edb19e 100644 --- a/src/compiler/utils/names.ts +++ b/src/compiler/utils/names.ts @@ -117,12 +117,6 @@ export const reserved = new Set([ 'yield' ]); -const void_element_names = /^(?:area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)$/; - -export function is_void(name: string) { - return void_element_names.test(name) || name.toLowerCase() === '!doctype'; -} - export function is_valid(str: string): boolean { let i = 0; diff --git a/src/runtime/internal/ssr.ts b/src/runtime/internal/ssr.ts index c4d7f02bf0..2eaaf8392e 100644 --- a/src/runtime/internal/ssr.ts +++ b/src/runtime/internal/ssr.ts @@ -1,7 +1,7 @@ import { set_current_component, current_component } from './lifecycle'; import { run_all, blank_object } from './utils'; import { boolean_attributes } from '../../compiler/compile/render_ssr/handlers/shared/boolean_attributes'; -export { is_void } from '../../compiler/utils/names'; +export { is_void } from '../../shared/utils/names'; export const invalid_attribute_name_character = /[\s'">/=\u{FDD0}-\u{FDEF}\u{FFFE}\u{FFFF}\u{1FFFE}\u{1FFFF}\u{2FFFE}\u{2FFFF}\u{3FFFE}\u{3FFFF}\u{4FFFE}\u{4FFFF}\u{5FFFE}\u{5FFFF}\u{6FFFE}\u{6FFFF}\u{7FFFE}\u{7FFFF}\u{8FFFE}\u{8FFFF}\u{9FFFE}\u{9FFFF}\u{AFFFE}\u{AFFFF}\u{BFFFE}\u{BFFFF}\u{CFFFE}\u{CFFFF}\u{DFFFE}\u{DFFFF}\u{EFFFE}\u{EFFFF}\u{FFFFE}\u{FFFFF}\u{10FFFE}\u{10FFFF}]/u; // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2 diff --git a/src/shared/utils/names.ts b/src/shared/utils/names.ts new file mode 100644 index 0000000000..5e13e6cd87 --- /dev/null +++ b/src/shared/utils/names.ts @@ -0,0 +1,5 @@ +const void_element_names = /^(?:area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)$/; + +export function is_void(name: string) { + return void_element_names.test(name) || name.toLowerCase() === '!doctype'; +}