|
|
@ -33,40 +33,36 @@ export function bind_content_editable(property, element, get_value, update) {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @param {string} property
|
|
|
|
* @param {string} property
|
|
|
|
* @param {string} event_name
|
|
|
|
* @param {string} event_name
|
|
|
|
* @param {'get' | 'set'} type
|
|
|
|
|
|
|
|
* @param {Element} element
|
|
|
|
* @param {Element} element
|
|
|
|
* @param {() => unknown} get_value
|
|
|
|
* @param {(value: unknown) => void} set
|
|
|
|
* @param {(value: unknown) => void} update
|
|
|
|
* @param {() => unknown} [get]
|
|
|
|
* @returns {void}
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
export function bind_property(property, event_name, type, element, get_value, update) {
|
|
|
|
export function bind_property(property, event_name, element, set, get) {
|
|
|
|
var target_handler = () => {
|
|
|
|
var handler = () => {
|
|
|
|
// @ts-ignore
|
|
|
|
// @ts-ignore
|
|
|
|
update(element[property]);
|
|
|
|
set(element[property]);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
element.addEventListener(event_name, target_handler);
|
|
|
|
element.addEventListener(event_name, handler);
|
|
|
|
|
|
|
|
|
|
|
|
if (type === 'set') {
|
|
|
|
if (get) {
|
|
|
|
render_effect(() => {
|
|
|
|
render_effect(() => {
|
|
|
|
// @ts-ignore
|
|
|
|
// @ts-ignore
|
|
|
|
element[property] = get_value();
|
|
|
|
element[property] = get();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
handler();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (type === 'get') {
|
|
|
|
// @ts-ignore
|
|
|
|
// @ts-ignore
|
|
|
|
if (element === document.body || element === window || element === document) {
|
|
|
|
update(element[property]);
|
|
|
|
render_effect(() => {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
render_effect(() => {
|
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
|
|
|
if (element === document.body || element === window || element === document) {
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
return () => {
|
|
|
|
element.removeEventListener(event_name, target_handler);
|
|
|
|
element.removeEventListener(event_name, handler);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|