diff --git a/src/internal/Component.js b/src/internal/Component.js index f707dfb18d..4a7293ddae 100644 --- a/src/internal/Component.js +++ b/src/internal/Component.js @@ -1,7 +1,6 @@ -import { add_render_callback, flush, intros, schedule_update, dirty_components } from './scheduler.js'; -import { current_component, set_current_component } from './lifecycle.js' -import { is_function, run, run_all, noop } from './utils.js'; -import { blank_object } from './utils.js'; +import { add_render_callback, flush, schedule_update, dirty_components } from './scheduler.js'; +import { current_component, set_current_component } from './lifecycle.js'; +import { blank_object, is_function, run, run_all, noop } from './utils.js'; import { children } from './dom.js'; export function bind(component, name, callback) { @@ -23,7 +22,7 @@ export function mount_component(component, target, anchor) { if (on_destroy) { on_destroy.push(...new_on_destroy); } else { - // Edge case — component was destroyed immediately, + // Edge case - component was destroyed immediately, // most likely as a result of a binding initialising run_all(new_on_destroy); } @@ -129,7 +128,7 @@ if (typeof HTMLElement !== 'undefined') { } connectedCallback() { - for (let key in this.$$.slotted) { + for (const key in this.$$.slotted) { this.appendChild(this.$$.slotted[key]); } } @@ -157,7 +156,7 @@ if (typeof HTMLElement !== 'undefined') { $set() { // overridden by instance, if it has props } - } + }; } export class SvelteComponent { @@ -193,7 +192,7 @@ export class SvelteComponentDev extends SvelteComponent { $destroy() { super.$destroy(); this.$destroy = () => { - console.warn(`Component was already destroyed`); + console.warn(`Component was already destroyed`); // eslint-disable-line no-console }; } } \ No newline at end of file diff --git a/src/internal/await-block.js b/src/internal/await-block.js index 60584b59e5..9e14c50342 100644 --- a/src/internal/await-block.js +++ b/src/internal/await-block.js @@ -3,7 +3,7 @@ import { check_outros, group_outros, on_outro } from './transitions.js'; import { flush } from '../internal/scheduler.js'; export function handle_promise(promise, info) { - var token = info.token = {}; + const token = info.token = {}; function update(type, index, key, value) { if (info.token !== token) return; diff --git a/src/internal/dom.js b/src/internal/dom.js index 3df4690a1e..1c22bf4c70 100644 --- a/src/internal/dom.js +++ b/src/internal/dom.js @@ -29,7 +29,7 @@ export function detach_after(before) { } export function destroy_each(iterations, detaching) { - for (var i = 0; i < iterations.length; i += 1) { + for (let i = 0; i < iterations.length; i += 1) { if (iterations[i]) iterations[i].d(detaching); } } @@ -79,7 +79,7 @@ export function attr(node, attribute, value) { } export function set_attributes(node, attributes) { - for (var key in attributes) { + for (const key in attributes) { if (key === 'style') { node.style.cssText = attributes[key]; } else if (key in node) { @@ -103,8 +103,8 @@ export function xlink_attr(node, attribute, value) { } export function get_binding_group_value(group) { - var value = []; - for (var i = 0; i < group.length; i += 1) { + const value = []; + for (let i = 0; i < group.length; i += 1) { if (group[i].checked) value.push(group[i].__value); } return value; @@ -115,8 +115,8 @@ export function to_number(value) { } export function time_ranges_to_array(ranges) { - var array = []; - for (var i = 0; i < ranges.length; i += 1) { + const array = []; + for (let i = 0; i < ranges.length; i += 1) { array.push({ start: ranges.start(i), end: ranges.end(i) }); } return array; @@ -127,11 +127,11 @@ export function children(element) { } export function claim_element(nodes, name, attributes, svg) { - for (var i = 0; i < nodes.length; i += 1) { - var node = nodes[i]; + for (let i = 0; i < nodes.length; i += 1) { + const node = nodes[i]; if (node.nodeName === name) { - for (var j = 0; j < node.attributes.length; j += 1) { - var attribute = node.attributes[j]; + for (let j = 0; j < node.attributes.length; j += 1) { + const attribute = node.attributes[j]; if (!attributes[attribute.name]) node.removeAttribute(attribute.name); } return nodes.splice(i, 1)[0]; // TODO strip unwanted attributes @@ -142,8 +142,8 @@ export function claim_element(nodes, name, attributes, svg) { } export function claim_text(nodes, data) { - for (var i = 0; i < nodes.length; i += 1) { - var node = nodes[i]; + for (let i = 0; i < nodes.length; i += 1) { + const node = nodes[i]; if (node.nodeType === 3) { node.data = data; return nodes.splice(i, 1)[0]; @@ -160,7 +160,9 @@ export function set_data(text, data) { export function set_input_type(input, type) { try { input.type = type; - } catch (e) {} + } catch (e) { + // do nothing + } } export function set_style(node, key, value) { @@ -168,8 +170,8 @@ export function set_style(node, key, value) { } export function select_option(select, value) { - for (var i = 0; i < select.options.length; i += 1) { - var option = select.options[i]; + for (let i = 0; i < select.options.length; i += 1) { + const option = select.options[i]; if (option.__value === value) { option.selected = true; @@ -179,21 +181,19 @@ export function select_option(select, value) { } export function select_options(select, value) { - for (var i = 0; i < select.options.length; i += 1) { - var option = select.options[i]; + for (let i = 0; i < select.options.length; i += 1) { + const option = select.options[i]; option.selected = ~value.indexOf(option.__value); } } export function select_value(select) { - var selectedOption = select.querySelector(':checked') || select.options[0]; - return selectedOption && selectedOption.__value; + const selected_option = select.querySelector(':checked') || select.options[0]; + return selected_option && selected_option.__value; } export function select_multiple_value(select) { - return [].map.call(select.querySelectorAll(':checked'), function(option) { - return option.__value; - }); + return [].map.call(select.querySelectorAll(':checked'), option => option.__value); } export function add_resize_listener(element, fn) { diff --git a/src/internal/keyed-each.js b/src/internal/keyed-each.js index e2ce67d13c..307a6b0dbc 100644 --- a/src/internal/keyed-each.js +++ b/src/internal/keyed-each.js @@ -19,22 +19,22 @@ export function fix_and_outro_and_destroy_block(block, lookup) { } export function update_keyed_each(old_blocks, changed, get_key, dynamic, ctx, list, lookup, node, destroy, create_each_block, next, get_context) { - var o = old_blocks.length; - var n = list.length; + let o = old_blocks.length; + let n = list.length; - var i = o; - var old_indexes = {}; + let i = o; + const old_indexes = {}; while (i--) old_indexes[old_blocks[i].key] = i; - var new_blocks = []; - var new_lookup = {}; - var deltas = {}; + const new_blocks = []; + const new_lookup = {}; + const deltas = {}; - var i = n; + i = n; while (i--) { - var child_ctx = get_context(ctx, list, i); - var key = get_key(child_ctx); - var block = lookup[key]; + const child_ctx = get_context(ctx, list, i); + const key = get_key(child_ctx); + let block = lookup[key]; if (!block) { block = create_each_block(key, child_ctx); @@ -48,8 +48,8 @@ export function update_keyed_each(old_blocks, changed, get_key, dynamic, ctx, li if (key in old_indexes) deltas[key] = Math.abs(i - old_indexes[key]); } - var will_move = {}; - var did_move = {}; + const will_move = {}; + const did_move = {}; function insert(block) { if (block.i) block.i(1); @@ -60,10 +60,10 @@ export function update_keyed_each(old_blocks, changed, get_key, dynamic, ctx, li } while (o && n) { - var new_block = new_blocks[n - 1]; - var old_block = old_blocks[o - 1]; - var new_key = new_block.key; - var old_key = old_block.key; + const new_block = new_blocks[n - 1]; + const old_block = old_blocks[o - 1]; + const new_key = new_block.key; + const old_key = old_block.key; if (new_block === old_block) { // do nothing @@ -96,7 +96,7 @@ export function update_keyed_each(old_blocks, changed, get_key, dynamic, ctx, li } while (o--) { - var old_block = old_blocks[o]; + const old_block = old_blocks[o]; if (!new_lookup[old_block.key]) destroy(old_block, lookup); } diff --git a/src/internal/scheduler.js b/src/internal/scheduler.js index 6c62af905c..b2b5bd5200 100644 --- a/src/internal/scheduler.js +++ b/src/internal/scheduler.js @@ -1,7 +1,7 @@ import { run_all } from './utils.js'; import { set_current_component } from './lifecycle.js'; -export let dirty_components = []; +export const dirty_components = []; export const intros = { enabled: false }; let update_promise; diff --git a/src/internal/spread.js b/src/internal/spread.js index 50617fe8fb..2b4c8c42d5 100644 --- a/src/internal/spread.js +++ b/src/internal/spread.js @@ -1,20 +1,20 @@ export function get_spread_update(levels, updates) { - var update = {}; + const update = {}; - var to_null_out = {}; - var accounted_for = {}; + const to_null_out = {}; + const accounted_for = {}; - var i = levels.length; + let i = levels.length; while (i--) { - var o = levels[i]; - var n = updates[i]; + const o = levels[i]; + const n = updates[i]; if (n) { - for (var key in o) { + for (const key in o) { if (!(key in n)) to_null_out[key] = 1; } - for (var key in n) { + for (const key in n) { if (!accounted_for[key]) { update[key] = n[key]; accounted_for[key] = 1; @@ -23,13 +23,13 @@ export function get_spread_update(levels, updates) { levels[i] = n; } else { - for (var key in o) { + for (const key in o) { accounted_for[key] = 1; } } } - for (var key in to_null_out) { + for (const key in to_null_out) { if (!(key in update)) update[key] = undefined; } diff --git a/src/internal/ssr.js b/src/internal/ssr.js index a86982ede8..e8d96c609c 100644 --- a/src/internal/ssr.js +++ b/src/internal/ssr.js @@ -1,7 +1,7 @@ import { set_current_component, current_component } from './lifecycle.js'; import { run_all, blank_object } from './utils.js'; -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; +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 // https://infra.spec.whatwg.org/#noncharacter @@ -60,8 +60,8 @@ export function validate_component(component, name) { } export function debug(file, line, column, values) { - console.log(`{@debug} ${file ? file + ' ' : ''}(${line}:${column})`); - console.log(values); + console.log(`{@debug} ${file ? file + ' ' : ''}(${line}:${column})`); // eslint-disable-line no-console + console.log(values); // eslint-disable-line no-console return ''; } diff --git a/src/internal/transitions.js b/src/internal/transitions.js index a6579b0cef..3649de2b0c 100644 --- a/src/internal/transitions.js +++ b/src/internal/transitions.js @@ -246,7 +246,7 @@ export function create_bidirectional_transition(node, fn, params, intro) { if (b) tick(0, 1); running_program = init(program, duration); - add_render_callback(() => dispatch(node, b, 'start')) + add_render_callback(() => dispatch(node, b, 'start')); loop(now => { if (pending_program && now > pending_program.start) { diff --git a/src/internal/utils.js b/src/internal/utils.js index 05ba599b22..5e2f8b1165 100644 --- a/src/internal/utils.js +++ b/src/internal/utils.js @@ -3,7 +3,7 @@ export function noop() {} export const identity = x => x; export function assign(tar, src) { - for (var k in src) tar[k] = src[k]; + for (const k in src) tar[k] = src[k]; return tar; } diff --git a/src/motion/spring.js b/src/motion/spring.js index 10189ef7d9..2a5824f088 100644 --- a/src/motion/spring.js +++ b/src/motion/spring.js @@ -1,5 +1,5 @@ -import { writable } from 'svelte/store'; -import { loop } from 'svelte/internal'; +import { writable } from 'svelte/store'; // eslint-disable-line import/no-unresolved +import { loop } from 'svelte/internal'; // eslint-disable-line import/no-unresolved import { is_date } from './utils.js'; function get_initial_velocity(value) { @@ -120,7 +120,7 @@ export function spring(value, opts = {}) { last_time = window.performance.now(); settled = false; - task = loop(now=> { + task = loop(now => { ({ value, settled } = tick_spring( velocity, value, diff --git a/src/motion/tweened.js b/src/motion/tweened.js index 49f1217a4e..a3b5f7331e 100644 --- a/src/motion/tweened.js +++ b/src/motion/tweened.js @@ -1,6 +1,6 @@ -import { writable } from 'svelte/store'; -import { assign, loop } from 'svelte/internal'; -import { linear } from 'svelte/easing'; +import { writable } from 'svelte/store'; // eslint-disable-line import/no-unresolved +import { assign, loop } from 'svelte/internal'; // eslint-disable-line import/no-unresolved +import { linear } from 'svelte/easing'; // eslint-disable-line import/no-unresolved import { is_date } from './utils.js'; function get_interpolator(a, b) {