|
|
|
|
@ -11,7 +11,6 @@ const readonly = new Set(['fullscreenElement', 'visibilityState']);
|
|
|
|
|
|
|
|
|
|
/** @extends Wrapper */
|
|
|
|
|
export default class DocumentWrapper extends Wrapper {
|
|
|
|
|
|
|
|
|
|
/** @type {import('../../nodes/Document.js').default} */
|
|
|
|
|
node;
|
|
|
|
|
|
|
|
|
|
@ -43,11 +42,12 @@ export default class DocumentWrapper extends Wrapper {
|
|
|
|
|
|
|
|
|
|
/** @type {Record<string, string>} */
|
|
|
|
|
const bindings = {};
|
|
|
|
|
add_event_handlers(block, x `@_document`, this.handlers);
|
|
|
|
|
add_actions(block, x `@_document`, this.node.actions);
|
|
|
|
|
add_event_handlers(block, x`@_document`, this.handlers);
|
|
|
|
|
add_actions(block, x`@_document`, this.node.actions);
|
|
|
|
|
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);
|
|
|
|
|
@ -56,8 +56,7 @@ export default class DocumentWrapper extends Wrapper {
|
|
|
|
|
const binding_events = associated_events[binding.name];
|
|
|
|
|
const property = binding.name;
|
|
|
|
|
binding_events.forEach((associated_event) => {
|
|
|
|
|
if (!events[associated_event])
|
|
|
|
|
events[associated_event] = [];
|
|
|
|
|
if (!events[associated_event]) events[associated_event] = [];
|
|
|
|
|
events[associated_event].push({
|
|
|
|
|
name: binding_name,
|
|
|
|
|
value: property
|
|
|
|
|
@ -70,24 +69,20 @@ export default class DocumentWrapper extends Wrapper {
|
|
|
|
|
renderer.add_to_context(id.name);
|
|
|
|
|
const fn = renderer.reference(id.name);
|
|
|
|
|
props.forEach((prop) => {
|
|
|
|
|
renderer.meta_bindings.push(b `this._state.${prop.name} = @_document.${prop.value};`);
|
|
|
|
|
renderer.meta_bindings.push(b`this._state.${prop.name} = @_document.${prop.value};`);
|
|
|
|
|
});
|
|
|
|
|
block.event_listeners.push(x `
|
|
|
|
|
block.event_listeners.push(x`
|
|
|
|
|
@listen(@_document, "${event}", ${fn})
|
|
|
|
|
`);
|
|
|
|
|
component.partly_hoisted.push(b `
|
|
|
|
|
component.partly_hoisted.push(b`
|
|
|
|
|
function ${id}() {
|
|
|
|
|
${props.map((prop) => renderer.invalidate(prop.name, x `${prop.name} = @_document.${prop.value}`))}
|
|
|
|
|
${props.map((prop) => renderer.invalidate(prop.name, x`${prop.name} = @_document.${prop.value}`))}
|
|
|
|
|
}
|
|
|
|
|
`);
|
|
|
|
|
block.chunks.init.push(b `
|
|
|
|
|
block.chunks.init.push(b`
|
|
|
|
|
@add_render_callback(${fn});
|
|
|
|
|
`);
|
|
|
|
|
component.has_reactive_assignments = true;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|