port runtime to typescript, move runtime/app.js to runtime.js

This commit is contained in:
Rich Harris
2017-12-25 17:14:39 -05:00
parent c29e8022cc
commit b3027c5816
11 changed files with 356 additions and 220 deletions

19
src/runtime/utils.ts Normal file
View File

@@ -0,0 +1,19 @@
export function detach(node: Node) {
node.parentNode.removeChild(node);
}
export function findAnchor(node: Node) {
while (node && node.nodeName.toUpperCase() !== 'A') node = node.parentNode; // SVG <a> elements have a lowercase name
return node;
}
export function which(event: MouseEvent) {
return event.which === null ? event.button : event.which;
}
export function scroll_state() {
return {
x: window.scrollX,
y: window.scrollY
};
}