use helper for combining window binding props

pull/1887/head
Rich Harris 6 years ago
parent d236a4ad0b
commit e5ae97b9c9

@ -3,6 +3,7 @@ import Block from '../Block';
import Node from '../../nodes/shared/Node'; import Node from '../../nodes/shared/Node';
import Wrapper from './shared/Wrapper'; import Wrapper from './shared/Wrapper';
import deindent from '../../../utils/deindent'; import deindent from '../../../utils/deindent';
import stringifyProps from '../../../utils/stringifyProps';
const associatedEvents = { const associatedEvents = {
innerWidth: 'resize', innerWidth: 'resize',
@ -147,9 +148,7 @@ export default class WindowWrapper extends Wrapper {
`} `}
${component.options.dev && `component._updatingReadonlyProperty = true;`} ${component.options.dev && `component._updatingReadonlyProperty = true;`}
#component.set({ #component.set(${stringifyProps(props.map(prop => `${prop.name}: this.${prop.value}`))});
${props.map(prop => `${prop.name}: this.${prop.value},`)}
});
${component.options.dev && `component._updatingReadonlyProperty = false;`} ${component.options.dev && `component._updatingReadonlyProperty = false;`}
${event === 'scroll' && `${lock} = false;`} ${event === 'scroll' && `${lock} = false;`}

@ -8,9 +8,7 @@ function create_main_fragment(component, ctx) {
if (window_updating) return; if (window_updating) return;
window_updating = true; window_updating = true;
component.set({ component.set({ y: this.pageYOffset });
y: this.pageYOffset
});
window_updating = false; window_updating = false;
} }
window.addEventListener("scroll", onwindowscroll); window.addEventListener("scroll", onwindowscroll);

Loading…
Cancel
Save