Lint and format src/compiler/compile/render_dom/wrappers/Window.js

pull/8569/head
Simon Holthausen 3 years ago
parent 9d5492ab27
commit f241b93ef3

@ -27,7 +27,6 @@ const readonly = new Set([
/** @extends Wrapper */
export default class WindowWrapper extends Wrapper {
/** @type {import('../../nodes/Window.js').default} */
node;
@ -63,19 +62,18 @@ export default class WindowWrapper extends Wrapper {
add_event_handlers(block, '@_window', this.handlers);
this.node.bindings.forEach((binding) => {
// TODO: what if it's a MemberExpression?
const binding_name = ( /** @type {import('estree').Identifier} */(binding.expression.node)).name;
const binding_name = /** @type {import('estree').Identifier} */ (binding.expression.node)
.name;
// in dev mode, throw if read-only values are written to
if (readonly.has(binding.name)) {
renderer.readonly.add(binding_name);
}
bindings[binding.name] = binding_name;
// bind:online is a special case, we need to listen for two separate events
if (binding.name === 'online')
return;
if (binding.name === 'online') return;
const associated_event = associated_events[binding.name];
const property = properties[binding.name] || binding.name;
if (!events[associated_event])
events[associated_event] = [];
if (!events[associated_event]) events[associated_event] = [];
events[associated_event].push({
name: binding_name,
value: property
@ -94,7 +92,8 @@ export default class WindowWrapper extends Wrapper {
block.add_variable(scrolling, x`false`);
block.add_variable(clear_scrolling, x`() => { ${scrolling} = false }`);
block.add_variable(scrolling_timeout);
const condition = bindings.scrollX && bindings.scrollY
const condition =
bindings.scrollX && bindings.scrollY
? x`"${bindings.scrollX}" in this._state || "${bindings.scrollY}" in this._state`
: x`"${bindings.scrollX || bindings.scrollY}" in this._state`;
const scrollX = bindings.scrollX && x`this._state.${bindings.scrollX}`;
@ -114,8 +113,7 @@ export default class WindowWrapper extends Wrapper {
${fn}();
})
`);
}
else {
} else {
props.forEach((prop) => {
renderer.meta_bindings.push(b`this._state.${prop.name} = @_window.${prop.value};`);
});
@ -165,12 +163,11 @@ export default class WindowWrapper extends Wrapper {
block.chunks.init.push(b`
@add_render_callback(${reference});
`);
block.event_listeners.push(x `@listen(@_window, "online", ${reference})`, x `@listen(@_window, "offline", ${reference})`);
block.event_listeners.push(
x`@listen(@_window, "online", ${reference})`,
x`@listen(@_window, "offline", ${reference})`
);
component.has_reactive_assignments = true;
}
}
}

Loading…
Cancel
Save