From eaf599f910c2bf11a5794ef0495a0765f50aedc7 Mon Sep 17 00:00:00 2001 From: pushkine Date: Sun, 10 May 2020 04:42:42 +0200 Subject: [PATCH] 10/05 --- .gitignore | 1 + environment/index.d.ts | 1 + environment/index.js | 24 ++ environment/index.mjs | 16 ++ environment/package.json | 5 + package.json | 199 +++++++------- src/ambient.ts | 40 +-- src/compiler/Stats.ts | 35 +-- src/compiler/compile/Component.ts | 50 ++-- src/compiler/compile/index.ts | 15 +- src/compiler/compile/nodes/Element.ts | 224 +++++++--------- src/compiler/compile/render_dom/Block.ts | 104 ++++--- src/compiler/compile/render_dom/index.ts | 253 ++++++++++-------- src/compiler/compile/render_dom/invalidate.ts | 45 ++-- .../compile/render_dom/wrappers/AwaitBlock.ts | 31 +-- .../compile/render_dom/wrappers/EachBlock.ts | 82 +++--- .../render_dom/wrappers/Element/Attribute.ts | 99 +++---- .../wrappers/Element/EventHandler.ts | 16 +- .../render_dom/wrappers/Element/index.ts | 20 +- .../compile/render_dom/wrappers/Fragment.ts | 24 +- .../compile/render_dom/wrappers/Head.ts | 19 +- .../compile/render_dom/wrappers/IfBlock.ts | 161 +++++------ .../wrappers/InlineComponent/index.ts | 21 +- .../render_dom/wrappers/shared/add_actions.ts | 22 +- .../render_ssr/handlers/InlineComponent.ts | 55 ++-- .../handlers/shared/get_attribute_value.ts | 4 +- .../utils/remove_whitespace_children.ts | 16 +- src/compiler/compile/render_ssr/index.ts | 91 +++---- src/compiler/compile/utils/get_slot_data.ts | 12 +- src/compiler/interfaces.ts | 10 +- src/compiler/parse/state/mustache.ts | 143 +++++----- src/compiler/parse/utils/html.ts | 11 +- src/compiler/utils/fuzzymatch.ts | 28 +- src/compiler/utils/link.ts | 6 +- src/compiler/utils/list.ts | 8 +- src/compiler/utils/names.ts | 2 +- src/compiler/utils/namespaces.ts | 37 +-- src/compiler/utils/nodes_match.ts | 10 +- src/runtime/easing/index.ts | 24 +- src/runtime/environment/index.ts | 14 + src/runtime/internal/Component.ts | 68 +++-- src/runtime/internal/await_block.ts | 33 +-- src/runtime/internal/dev.legacy.ts | 29 +- src/runtime/internal/dev.tools.ts | 148 ++++++++++ src/runtime/internal/dev.ts | 214 --------------- src/runtime/internal/dev.utils.ts | 56 ++++ src/runtime/internal/dom.ts | 70 ++--- src/runtime/internal/environment.ts | 32 ++- src/runtime/internal/globals.ts | 7 - src/runtime/internal/index.ts | 4 +- src/runtime/internal/keyed_each.ts | 70 ++--- src/runtime/internal/lifecycle.ts | 21 +- src/runtime/internal/loop.ts | 1 - src/runtime/internal/scheduler.ts | 117 +++++--- src/runtime/internal/spread.ts | 45 +--- src/runtime/internal/ssr.ts | 37 +-- src/runtime/internal/style_manager.ts | 2 +- src/runtime/internal/transitions.ts | 72 ++--- src/runtime/internal/utils.ts | 120 ++------- src/runtime/store/index.ts | 16 +- src/runtime/transition/index.ts | 16 +- src/runtime/tsconfig.json | 4 +- 62 files changed, 1487 insertions(+), 1673 deletions(-) create mode 100644 environment/index.d.ts create mode 100644 environment/index.js create mode 100644 environment/index.mjs create mode 100644 environment/package.json create mode 100644 src/runtime/environment/index.ts create mode 100644 src/runtime/internal/dev.tools.ts delete mode 100644 src/runtime/internal/dev.ts create mode 100644 src/runtime/internal/dev.utils.ts delete mode 100644 src/runtime/internal/globals.ts diff --git a/.gitignore b/.gitignore index 516738b185..8d47cb279e 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ node_modules /dev /store /easing +/interpolate /motion /transition /animate diff --git a/environment/index.d.ts b/environment/index.d.ts new file mode 100644 index 0000000000..01c73ad465 --- /dev/null +++ b/environment/index.d.ts @@ -0,0 +1 @@ +export * from '../types/runtime/environment/index'; \ No newline at end of file diff --git a/environment/index.js b/environment/index.js new file mode 100644 index 0000000000..7f05d955cc --- /dev/null +++ b/environment/index.js @@ -0,0 +1,24 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +const is_browser = typeof window !== 'undefined'; +const is_iframe = is_browser && window.self !== window.top; +const is_cors = + is_iframe && + (() => { + try { + if (window.parent) void window.parent.document; + return false; + } catch (error) { + return true; + } + })(); +const has_Symbol = typeof Symbol === 'function'; +const globals = is_browser ? window : typeof globalThis !== 'undefined' ? globalThis : global; + +exports.globals = globals; +exports.has_Symbol = has_Symbol; +exports.is_browser = is_browser; +exports.is_cors = is_cors; +exports.is_iframe = is_iframe; diff --git a/environment/index.mjs b/environment/index.mjs new file mode 100644 index 0000000000..578e83c99e --- /dev/null +++ b/environment/index.mjs @@ -0,0 +1,16 @@ +const is_browser = typeof window !== 'undefined'; +const is_iframe = is_browser && window.self !== window.top; +const is_cors = + is_iframe && + (() => { + try { + if (window.parent) void window.parent.document; + return false; + } catch (error) { + return true; + } + })(); +const has_Symbol = typeof Symbol === 'function'; +const globals = is_browser ? window : typeof globalThis !== 'undefined' ? globalThis : global; + +export { globals, has_Symbol, is_browser, is_cors, is_iframe }; diff --git a/environment/package.json b/environment/package.json new file mode 100644 index 0000000000..e106ca54ab --- /dev/null +++ b/environment/package.json @@ -0,0 +1,5 @@ +{ + "main": "./index", + "module": "./index.mjs", + "types": "./index.d.ts" + } \ No newline at end of file diff --git a/package.json b/package.json index 88b9a26bfe..87885369dc 100644 --- a/package.json +++ b/package.json @@ -1,103 +1,100 @@ { - "name": "svelte", - "version": "3.21.0", - "description": "Cybernetically enhanced web apps", - "module": "index.mjs", - "main": "index", - "files": [ - "types", - "compiler.*", - "register.js", - "index.*", - "internal", - "store", - "animate", - "transition", - "easing", - "motion", - "svelte", - "README.md" - ], - "engines": { - "node": ">= 8" - }, - "types": "types/runtime/index.d.ts", - "scripts": { - "test": "mocha --opts mocha.opts", - "test:unit": "mocha --require sucrase/register --recursive src/**/__test__.ts", - "quicktest": "mocha --opts mocha.opts", - "precoverage": "c8 mocha --opts mocha.coverage.opts", - "coverage": "c8 report --reporter=text-lcov > coverage.lcov && c8 report --reporter=html", - "codecov": "codecov", - "precodecov": "npm run coverage", - "build": "rollup -c && npm run tsd", - "prepare": "npm run build", - "dev": "rollup -cw", - "pretest": "npm run build", - "posttest": "agadoo internal/index.mjs", - "prepublishOnly": "npm run lint && PUBLISH=true npm test", - "tsd": "tsc -p src/compiler --emitDeclarationOnly && tsc -p src/runtime --emitDeclarationOnly", - "lint": "eslint \"{src,test}/**/*.{ts,js}\"" - }, - "repository": { - "type": "git", - "url": "https://github.com/sveltejs/svelte.git" - }, - "keywords": [ - "UI", - "framework", - "templates", - "templating" - ], - "author": "Rich Harris", - "license": "MIT", - "bugs": { - "url": "https://github.com/sveltejs/svelte/issues" - }, - "homepage": "https://github.com/sveltejs/svelte#README", - "devDependencies": { - "@rollup/plugin-commonjs": "^11.1.0", - "@rollup/plugin-json": "^4.0.3", - "@rollup/plugin-node-resolve": "^7.1.3", - "@rollup/plugin-replace": "^2.3.2", - "@rollup/plugin-sucrase": "^3.0.0", - "@rollup/plugin-typescript": "^4.1.1", - "@rollup/plugin-virtual": "^2.0.1", - "@types/mocha": "^7.0.2", - "@types/node": "^13.13.4", - "@typescript-eslint/eslint-plugin": "^2.30.0", - "@typescript-eslint/parser": "^2.30.0", - "acorn": "^7.1.1", - "agadoo": "^2.0.0", - "c8": "^7.1.1", - "code-red": "0.1.1", - "codecov": "^3.6.5", - "css-tree": "1.0.0-alpha22", - "eslint": "^6.8.0", - "eslint-plugin-import": "^2.20.2", - "eslint-plugin-svelte3": "^2.7.3", - "estree-walker": "^2.0.1", - "is-reference": "^1.1.4", - "jsdom": "^16.2.2", - "kleur": "^3.0.3", - "locate-character": "^2.0.5", - "magic-string": "^0.25.7", - "mocha": "^7.1.2", - "periscopic": "^2.0.2", - "puppeteer": "^3.0.2", - "rollup": "^2.7.6", - "source-map": "^0.7.3", - "source-map-support": "^0.5.19", - "tiny-glob": "^0.2.6", - "tslib": "^1.11.1", - "typescript": "^3.8.3" - }, - "nyc": { - "include": [ - "compiler/svelte.js", - "shared.js" - ], - "sourceMap": true, - "instrument": true - } + "name": "svelte", + "version": "3.21.0", + "description": "Cybernetically enhanced web apps", + "module": "index.mjs", + "main": "index", + "files": [ + "types", + "compiler.*", + "register.js", + "index.*", + "internal", + "store", + "animate", + "transition", + "easing", + "motion", + "svelte", + "README.md" + ], + "types": "types/runtime/index.d.ts", + "scripts": { + "test": "mocha --opts mocha.opts", + "test:unit": "mocha --require sucrase/register --recursive src/**/__test__.ts", + "quicktest": "mocha --opts mocha.opts", + "precoverage": "c8 mocha --opts mocha.coverage.opts", + "coverage": "c8 report --reporter=text-lcov > coverage.lcov && c8 report --reporter=html", + "codecov": "codecov", + "precodecov": "npm run coverage", + "build": "rollup -c && npm run tsd", + "prepare": "npm run build", + "dev": "rollup -cw", + "pretest": "npm run build", + "posttest": "agadoo internal/index.mjs", + "prepublishOnly": "npm run lint && PUBLISH=true npm test", + "tsd": "tsc -p src/compiler --emitDeclarationOnly && tsc -p src/runtime --emitDeclarationOnly", + "lint": "eslint \"{src,test}/**/*.{ts,js}\"" + }, + "repository": { + "type": "git", + "url": "https://github.com/sveltejs/svelte.git" + }, + "keywords": [ + "UI", + "framework", + "templates", + "templating" + ], + "author": "Rich Harris", + "license": "MIT", + "bugs": { + "url": "https://github.com/sveltejs/svelte/issues" + }, + "homepage": "https://github.com/sveltejs/svelte#README", + "devDependencies": { + "@rollup/plugin-commonjs": "^11.1.0", + "@rollup/plugin-json": "^4.0.3", + "@rollup/plugin-node-resolve": "^7.1.3", + "@rollup/plugin-replace": "^2.3.2", + "@rollup/plugin-sucrase": "^3.0.0", + "@rollup/plugin-typescript": "^4.1.1", + "@rollup/plugin-virtual": "^2.0.1", + "@types/mocha": "^7.0.2", + "@types/node": "^13.13.5", + "@typescript-eslint/eslint-plugin": "^2.31.0", + "@typescript-eslint/parser": "^2.31.0", + "acorn": "^7.2.0", + "agadoo": "^2.0.0", + "c8": "^7.1.2", + "code-red": "0.1.1", + "codecov": "^3.6.5", + "css-tree": "1.0.0-alpha22", + "eslint": "^7.0.0", + "eslint-plugin-import": "^2.20.2", + "eslint-plugin-svelte3": "^2.7.3", + "estree-walker": "^2.0.1", + "is-reference": "^1.1.4", + "jsdom": "^16.2.2", + "kleur": "^3.0.3", + "locate-character": "^2.0.5", + "magic-string": "^0.25.7", + "mocha": "^7.1.2", + "periscopic": "^2.0.1", + "puppeteer": "^3.0.4", + "rollup": "^2.8.2", + "source-map": "^0.7.3", + "source-map-support": "^0.5.19", + "tiny-glob": "^0.2.6", + "tslib": "^1.11.2", + "typescript": "^3.8.3" + }, + "nyc": { + "include": [ + "compiler/svelte.js", + "shared.js" + ], + "sourceMap": true, + "instrument": true + } } diff --git a/src/ambient.ts b/src/ambient.ts index 12defbaa3c..48b2439a92 100644 --- a/src/ambient.ts +++ b/src/ambient.ts @@ -1,46 +1,46 @@ /** * __DEV__ - * + * * Used in src/runtime - * + * * Bundles dev runtime to svelte/dev/[library].[m]js * the compiler rewrites its own 'svelte' imports to 'svelte/dev' automatically - * + * */ declare var __DEV__: boolean; /** * __VERSION__ - * - * Svelte's version in package.json + * + * Svelte's version in package.json * Used in src/compiler and src/runtime - * + * */ declare var __VERSION__: string; /** * __COMPILER_API_VERSION__ - * + * * Unique ID passed to the compiler * Used to mitigate breaking changes with bundler plugins - * + * * VERSIONS ( default is "3.0.0" ) - * - * >3.22.0 : { - * + * + * >3.22.0 : { + * * The change : - * A different runtime is now used in dev mode, + * A different runtime is now used in dev mode, * every import has to go through 'svelte/dev' instead of 'svelte' - * + * * Requirement : * In dev mode, bundler plugins must make sure that every 'svelte' import is replaced by 'svelte/dev' - * + * * } - * + * */ //declare var __COMPILER_API_VERSION__: boolean; /** * Unique ID devtools must pass to the compiler - * Used to - * + * Used to + * * VERSIONS ( default is "^3.21.0" ) * - 0 (default) : compiler imports from prod runtime * - 1 : in dev mode, compiler imports from dev runtime @@ -49,7 +49,9 @@ declare var __VERSION__: string; /** * TODO - * Bundle different runtime for tests + * Bundle different runtime for tests * instead of relying on hacks */ -declare var __TEST__: boolean; \ No newline at end of file +declare var __TEST__: boolean; + +declare var global: any; diff --git a/src/compiler/Stats.ts b/src/compiler/Stats.ts index 200fa448e9..1c3ba9fe77 100644 --- a/src/compiler/Stats.ts +++ b/src/compiler/Stats.ts @@ -1,9 +1,10 @@ -const now = (typeof process !== 'undefined' && process.hrtime) - ? () => { - const t = process.hrtime(); - return t[0] * 1e3 + t[1] / 1e6; - } - : () => self.performance.now(); +const now = + typeof process !== 'undefined' && process.hrtime + ? () => { + const t = process.hrtime(); + return t[0] * 1e3 + t[1] / 1e6; + } + : () => self.performance.now(); interface Timing { label: string; @@ -14,10 +15,13 @@ interface Timing { function collapse_timings(timings) { const result = {}; - timings.forEach(timing => { - result[timing.label] = Object.assign({ - total: timing.end - timing.start - }, timing.children && collapse_timings(timing.children)); + timings.forEach((timing) => { + result[timing.label] = Object.assign( + { + total: timing.end - timing.start, + }, + timing.children && collapse_timings(timing.children) + ); }); return result; } @@ -40,7 +44,7 @@ export default class Stats { label, start: now(), end: null, - children: [] + children: [], }; this.current_children.push(timing); @@ -62,12 +66,13 @@ export default class Stats { } render() { - const timings = Object.assign({ - total: now() - this.start_time - }, collapse_timings(this.timings)); + const timings = { + total: now() - this.start_time, + ...collapse_timings(this.timings), + }; return { - timings + timings, }; } } diff --git a/src/compiler/compile/Component.ts b/src/compiler/compile/Component.ts index 04b3bfc212..72944eb179 100644 --- a/src/compiler/compile/Component.ts +++ b/src/compiler/compile/Component.ts @@ -1,37 +1,37 @@ +import { b, print, x } from 'code-red'; +import { + AssignmentExpression, + ExpressionStatement, + Identifier, + ImportDeclaration, + Literal, + Node, + Program, +} from 'estree'; import { walk } from 'estree-walker'; +import is_reference from 'is-reference'; import { getLocator } from 'locate-character'; +import { test } from '../config'; +import { Ast, CompileOptions, CssResult, Var, Warning } from '../interfaces'; import Stats from '../Stats'; -import { globals, reserved, is_valid } from '../utils/names'; -import { namespaces, valid_namespaces } from '../utils/namespaces'; +import error from '../utils/error'; +import fuzzymatch from '../utils/fuzzymatch'; +import get_code_frame from '../utils/get_code_frame'; +import { globals, is_valid, reserved } from '../utils/names'; +import { namespaces } from '../utils/namespaces'; import create_module from './create_module'; -import { create_scopes, extract_names, Scope, extract_identifiers } from './utils/scope'; import Stylesheet from './css/Stylesheet'; -import { test } from '../config'; -import Fragment from './nodes/Fragment'; import internal_exports from './internal_exports'; -import { Ast, CompileOptions, Var, Warning, CssResult } from '../interfaces'; -import error from '../utils/error'; -import get_code_frame from '../utils/get_code_frame'; -import flatten_reference from './utils/flatten_reference'; -import is_used_as_reference from './utils/is_used_as_reference'; -import is_reference from 'is-reference'; +import Fragment from './nodes/Fragment'; import TemplateScope from './nodes/shared/TemplateScope'; -import fuzzymatch from '../utils/fuzzymatch'; -import get_object from './utils/get_object'; import Slot from './nodes/Slot'; -import { - Node, - ImportDeclaration, - Identifier, - Program, - ExpressionStatement, - AssignmentExpression, - Literal, -} from 'estree'; import add_to_set from './utils/add_to_set'; import check_graph_for_cycles from './utils/check_graph_for_cycles'; -import { print, x, b } from 'code-red'; +import flatten_reference from './utils/flatten_reference'; +import get_object from './utils/get_object'; +import is_used_as_reference from './utils/is_used_as_reference'; import { is_reserved_keyword } from './utils/reserved_keywords'; +import { create_scopes, extract_identifiers, extract_names, Scope } from './utils/scope'; interface ComponentOptions { namespace?: string; @@ -1343,8 +1343,8 @@ function process_component_options(component: Component, nodes) { if (typeof ns !== 'string') component.error(attribute, { code, message }); - if (valid_namespaces.indexOf(ns) === -1) { - const match = fuzzymatch(ns, valid_namespaces); + if (!(ns in namespaces)) { + const match = fuzzymatch(ns, namespaces); if (match) { component.error(attribute, { code: `invalid-namespace-property`, diff --git a/src/compiler/compile/index.ts b/src/compiler/compile/index.ts index 12b161aeeb..003c26a82d 100644 --- a/src/compiler/compile/index.ts +++ b/src/compiler/compile/index.ts @@ -1,4 +1,3 @@ -import { assign } from '../../runtime/internal/utils'; import Stats from '../Stats'; import parse from '../parse/index'; import render_dom from './render_dom/index'; @@ -9,6 +8,7 @@ import fuzzymatch from '../utils/fuzzymatch'; import get_name_from_filename from './utils/get_name_from_filename'; const valid_options = [ + 'version', 'format', 'name', 'filename', @@ -26,13 +26,13 @@ const valid_options = [ 'css', 'loopGuardTimeout', 'preserveComments', - 'preserveWhitespace' + 'preserveWhitespace', ]; function validate_options(options: CompileOptions, warnings: Warning[]) { const { name, filename, loopGuardTimeout, dev } = options; - Object.keys(options).forEach(key => { + Object.keys(options).forEach((key) => { if (!valid_options.includes(key)) { const match = fuzzymatch(key, valid_options); let message = `Unrecognized option '${key}'`; @@ -68,7 +68,7 @@ function validate_options(options: CompileOptions, warnings: Warning[]) { } export default function compile(source: string, options: CompileOptions = {}) { - options = assign({ generate: 'dom', dev: false }, options); + options = { generate: 'dom', dev: false, ...options }; const stats = new Stats(); const warnings = []; @@ -90,9 +90,10 @@ export default function compile(source: string, options: CompileOptions = {}) { ); stats.stop('create component'); - const result = options.generate === false - ? null - : options.generate === 'ssr' + const result = + options.generate === false + ? null + : options.generate === 'ssr' ? render_ssr(component, options) : render_dom(component, options); diff --git a/src/compiler/compile/nodes/Element.ts b/src/compiler/compile/nodes/Element.ts index 8ff36de31a..f786255518 100644 --- a/src/compiler/compile/nodes/Element.ts +++ b/src/compiler/compile/nodes/Element.ts @@ -19,10 +19,14 @@ import { INode } from './interfaces'; const svg = /^(?:altGlyph|altGlyphDef|altGlyphItem|animate|animateColor|animateMotion|animateTransform|circle|clipPath|color-profile|cursor|defs|desc|discard|ellipse|feBlend|feColorMatrix|feComponentTransfer|feComposite|feConvolveMatrix|feDiffuseLighting|feDisplacementMap|feDistantLight|feDropShadow|feFlood|feFuncA|feFuncB|feFuncG|feFuncR|feGaussianBlur|feImage|feMerge|feMergeNode|feMorphology|feOffset|fePointLight|feSpecularLighting|feSpotLight|feTile|feTurbulence|filter|font|font-face|font-face-format|font-face-name|font-face-src|font-face-uri|foreignObject|g|glyph|glyphRef|hatch|hatchpath|hkern|image|line|linearGradient|marker|mask|mesh|meshgradient|meshpatch|meshrow|metadata|missing-glyph|mpath|path|pattern|polygon|polyline|radialGradient|rect|set|solidcolor|stop|svg|switch|symbol|text|textPath|tref|tspan|unknown|use|view|vkern)$/; -const aria_attributes = 'activedescendant atomic autocomplete busy checked colindex controls current describedby details disabled dropeffect errormessage expanded flowto grabbed haspopup hidden invalid keyshortcuts label labelledby level live modal multiline multiselectable orientation owns placeholder posinset pressed readonly relevant required roledescription rowindex selected setsize sort valuemax valuemin valuenow valuetext'.split(' '); +const aria_attributes = 'activedescendant atomic autocomplete busy checked colindex controls current describedby details disabled dropeffect errormessage expanded flowto grabbed haspopup hidden invalid keyshortcuts label labelledby level live modal multiline multiselectable orientation owns placeholder posinset pressed readonly relevant required roledescription rowindex selected setsize sort valuemax valuemin valuenow valuetext'.split( + ' ' +); const aria_attribute_set = new Set(aria_attributes); -const aria_roles = 'alert alertdialog application article banner button cell checkbox columnheader combobox command complementary composite contentinfo definition dialog directory document feed figure form grid gridcell group heading img input landmark link list listbox listitem log main marquee math menu menubar menuitem menuitemcheckbox menuitemradio navigation none note option presentation progressbar radio radiogroup range region roletype row rowgroup rowheader scrollbar search searchbox section sectionhead select separator slider spinbutton status structure switch tab table tablist tabpanel term textbox timer toolbar tooltip tree treegrid treeitem widget window'.split(' '); +const aria_roles = 'alert alertdialog application article banner button cell checkbox columnheader combobox command complementary composite contentinfo definition dialog directory document feed figure form grid gridcell group heading img input landmark link list listbox listitem log main marquee math menu menubar menuitem menuitemcheckbox menuitemradio navigation none note option presentation progressbar radio radiogroup range region roletype row rowgroup rowheader scrollbar search searchbox section sectionhead select separator slider spinbutton status structure switch tab table tablist tabpanel term textbox timer toolbar tooltip tree treegrid treeitem widget window'.split( + ' ' +); const aria_role_set = new Set(aria_roles); const a11y_required_attributes = { @@ -35,13 +39,10 @@ const a11y_required_attributes = { // iframe-has-title iframe: ['title'], img: ['alt'], - object: ['title', 'aria-label', 'aria-labelledby'] + object: ['title', 'aria-label', 'aria-labelledby'], }; -const a11y_distracting_elements = new Set([ - 'blink', - 'marquee' -]); +const a11y_distracting_elements = new Set(['blink', 'marquee']); const a11y_required_content = new Set([ // anchor-has-content @@ -53,35 +54,20 @@ const a11y_required_content = new Set([ 'h3', 'h4', 'h5', - 'h6' + 'h6', ]); const invisible_elements = new Set(['meta', 'html', 'script', 'style']); -const valid_modifiers = new Set([ - 'preventDefault', - 'stopPropagation', - 'capture', - 'once', - 'passive', - 'self' -]); +const valid_modifiers = new Set(['preventDefault', 'stopPropagation', 'capture', 'once', 'passive', 'self']); -const passive_events = new Set([ - 'wheel', - 'touchstart', - 'touchmove', - 'touchend', - 'touchcancel' -]); +const passive_events = new Set(['wheel', 'touchstart', 'touchmove', 'touchend', 'touchcancel']); function get_namespace(parent: Element, element: Element, explicit_namespace: string) { const parent_element = parent.find_nearest(/^Element/); if (!parent_element) { - return explicit_namespace || (svg.test(element.name) - ? namespaces.svg - : null); + return explicit_namespace || (svg.test(element.name) ? namespaces.svg : null); } if (svg.test(element.name.toLowerCase())) return namespaces.svg; @@ -115,11 +101,11 @@ export default class Element extends Node { if (this.name === 'textarea') { if (info.children.length > 0) { - const value_attribute = info.attributes.find(node => node.name === 'value'); + const value_attribute = info.attributes.find((node) => node.name === 'value'); if (value_attribute) { component.error(value_attribute, { code: `textarea-duplicate-value`, - message: `A