interpreter.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929
  1. class ListenerMap {
  2. constructor(root) {
  3. // bubbling events can listen at the root element
  4. this.global = {};
  5. // non bubbling events listen at the element the listener was created at
  6. this.local = {};
  7. this.root = root;
  8. }
  9. create(event_name, element, handler, bubbles) {
  10. if (bubbles) {
  11. if (this.global[event_name] === undefined) {
  12. this.global[event_name] = {};
  13. this.global[event_name].active = 1;
  14. this.global[event_name].callback = handler;
  15. this.root.addEventListener(event_name, handler);
  16. } else {
  17. this.global[event_name].active++;
  18. }
  19. }
  20. else {
  21. const id = element.getAttribute("data-dioxus-id");
  22. if (!this.local[id]) {
  23. this.local[id] = {};
  24. }
  25. this.local[id][event_name] = handler;
  26. element.addEventListener(event_name, handler);
  27. }
  28. }
  29. remove(element, event_name, bubbles) {
  30. if (bubbles) {
  31. this.global[event_name].active--;
  32. if (this.global[event_name].active === 0) {
  33. this.root.removeEventListener(event_name, this.global[event_name].callback);
  34. delete this.global[event_name];
  35. }
  36. }
  37. else {
  38. const id = element.getAttribute("data-dioxus-id");
  39. delete this.local[id][event_name];
  40. if (this.local[id].length === 0) {
  41. delete this.local[id];
  42. }
  43. element.removeEventListener(event_name, handler);
  44. }
  45. }
  46. removeAllNonBubbling(element) {
  47. const id = element.getAttribute("data-dioxus-id");
  48. delete this.local[id];
  49. }
  50. }
  51. class Interpreter {
  52. constructor(root) {
  53. this.root = root;
  54. this.listeners = new ListenerMap(root);
  55. this.nodes = [root];
  56. this.stack = [root];
  57. this.handlers = {};
  58. this.templates = {};
  59. this.lastNodeWasText = false;
  60. }
  61. top() {
  62. return this.stack[this.stack.length - 1];
  63. }
  64. pop() {
  65. return this.stack.pop();
  66. }
  67. MountToRoot() {
  68. this.AppendChildren(this.stack.length - 1);
  69. }
  70. SetNode(id, node) {
  71. this.nodes[id] = node;
  72. }
  73. PushRoot(root) {
  74. const node = this.nodes[root];
  75. this.stack.push(node);
  76. }
  77. PopRoot() {
  78. this.stack.pop();
  79. }
  80. AppendChildren(many) {
  81. // let root = this.nodes[id];
  82. let root = this.stack[this.stack.length - 1 - many];
  83. let to_add = this.stack.splice(this.stack.length - many);
  84. for (let i = 0; i < many; i++) {
  85. root.appendChild(to_add[i]);
  86. }
  87. }
  88. ReplaceWith(root_id, m) {
  89. let root = this.nodes[root_id];
  90. let els = this.stack.splice(this.stack.length - m);
  91. if (is_element_node(root.nodeType)) {
  92. this.listeners.removeAllNonBubbling(root);
  93. }
  94. root.replaceWith(...els);
  95. }
  96. InsertAfter(root, n) {
  97. let old = this.nodes[root];
  98. let new_nodes = this.stack.splice(this.stack.length - n);
  99. old.after(...new_nodes);
  100. }
  101. InsertBefore(root, n) {
  102. let old = this.nodes[root];
  103. let new_nodes = this.stack.splice(this.stack.length - n);
  104. old.before(...new_nodes);
  105. }
  106. Remove(root) {
  107. let node = this.nodes[root];
  108. if (node !== undefined) {
  109. if (is_element_node(node)) {
  110. this.listeners.removeAllNonBubbling(node);
  111. }
  112. node.remove();
  113. }
  114. }
  115. CreateRawText(text) {
  116. this.stack.push(document.createTextNode(text));
  117. }
  118. CreateTextNode(text, root) {
  119. const node = document.createTextNode(text);
  120. this.nodes[root] = node;
  121. this.stack.push(node);
  122. }
  123. CreatePlaceholder(root) {
  124. let el = document.createElement("pre");
  125. el.hidden = true;
  126. this.stack.push(el);
  127. this.nodes[root] = el;
  128. }
  129. NewEventListener(event_name, root, bubbles, handler) {
  130. const element = this.nodes[root];
  131. element.setAttribute("data-dioxus-id", `${root}`);
  132. this.listeners.create(event_name, element, handler, bubbles);
  133. }
  134. RemoveEventListener(root, event_name, bubbles) {
  135. const element = this.nodes[root];
  136. element.removeAttribute(`data-dioxus-id`);
  137. this.listeners.remove(element, event_name, bubbles);
  138. }
  139. SetText(root, text) {
  140. this.nodes[root].textContent = text;
  141. }
  142. SetAttribute(id, field, value, ns) {
  143. if (value === null) {
  144. this.RemoveAttribute(id, field, ns);
  145. }
  146. else {
  147. const node = this.nodes[id];
  148. this.SetAttributeInner(node, field, value, ns);
  149. }
  150. }
  151. SetAttributeInner(node, field, value, ns) {
  152. const name = field;
  153. if (ns === "style") {
  154. // ????? why do we need to do this
  155. if (node.style === undefined) {
  156. node.style = {};
  157. }
  158. node.style[name] = value;
  159. } else if (ns != null && ns != undefined) {
  160. node.setAttributeNS(ns, name, value);
  161. } else {
  162. switch (name) {
  163. case "value":
  164. if (value !== node.value) {
  165. node.value = value;
  166. }
  167. break;
  168. case "checked":
  169. node.checked = value === "true";
  170. break;
  171. case "selected":
  172. node.selected = value === "true";
  173. break;
  174. case "dangerous_inner_html":
  175. node.innerHTML = value;
  176. break;
  177. default:
  178. // https://github.com/facebook/react/blob/8b88ac2592c5f555f315f9440cbb665dd1e7457a/packages/react-dom/src/shared/DOMProperty.js#L352-L364
  179. if (value === "false" && bool_attrs.hasOwnProperty(name)) {
  180. node.removeAttribute(name);
  181. } else {
  182. node.setAttribute(name, value);
  183. }
  184. }
  185. }
  186. }
  187. RemoveAttribute(root, field, ns) {
  188. const name = field;
  189. const node = this.nodes[root];
  190. if (ns == "style") {
  191. node.style.removeProperty(name);
  192. } else if (ns !== null || ns !== undefined) {
  193. node.removeAttributeNS(ns, name);
  194. } else if (name === "value") {
  195. node.value = "";
  196. } else if (name === "checked") {
  197. node.checked = false;
  198. } else if (name === "selected") {
  199. node.selected = false;
  200. } else if (name === "dangerous_inner_html") {
  201. node.innerHTML = "";
  202. } else {
  203. node.removeAttribute(name);
  204. }
  205. }
  206. handleEdits(edits) {
  207. for (let template of edits.templates) {
  208. this.SaveTemplate(template);
  209. }
  210. for (let edit of edits.edits) {
  211. this.handleEdit(edit);
  212. }
  213. }
  214. SaveTemplate(template) {
  215. let roots = [];
  216. for (let root of template.roots) {
  217. roots.push(this.MakeTemplateNode(root));
  218. }
  219. this.templates[template.name] = roots;
  220. }
  221. MakeTemplateNode(node) {
  222. switch (node.type) {
  223. case "Text":
  224. return document.createTextNode(node.text);
  225. case "Dynamic":
  226. let dyn = document.createElement("pre");
  227. dyn.hidden = true;
  228. return dyn;
  229. case "DynamicText":
  230. return document.createTextNode("placeholder");
  231. case "Element":
  232. let el;
  233. if (node.namespace != null) {
  234. el = document.createElementNS(node.namespace, node.tag);
  235. } else {
  236. el = document.createElement(node.tag);
  237. }
  238. for (let attr of node.attrs) {
  239. if (attr.type == "Static") {
  240. this.SetAttributeInner(el, attr.name, attr.value, attr.namespace);
  241. }
  242. }
  243. for (let child of node.children) {
  244. el.appendChild(this.MakeTemplateNode(child));
  245. }
  246. return el;
  247. }
  248. }
  249. AssignId(path, id) {
  250. this.nodes[id] = this.LoadChild(path);
  251. }
  252. LoadChild(path) {
  253. // iterate through each number and get that child
  254. let node = this.stack[this.stack.length - 1];
  255. for (let i = 0; i < path.length; i++) {
  256. node = node.childNodes[path[i]];
  257. }
  258. return node;
  259. }
  260. HydrateText(path, value, id) {
  261. let node = this.LoadChild(path);
  262. if (node.nodeType == Node.TEXT_NODE) {
  263. node.textContent = value;
  264. } else {
  265. // replace with a textnode
  266. let text = document.createTextNode(value);
  267. node.replaceWith(text);
  268. node = text;
  269. }
  270. this.nodes[id] = node;
  271. }
  272. ReplacePlaceholder(path, m) {
  273. let els = this.stack.splice(this.stack.length - m);
  274. let node = this.LoadChild(path);
  275. node.replaceWith(...els);
  276. }
  277. LoadTemplate(name, index, id) {
  278. let node = this.templates[name][index].cloneNode(true);
  279. this.nodes[id] = node;
  280. this.stack.push(node);
  281. }
  282. handleEdit(edit) {
  283. switch (edit.type) {
  284. case "AppendChildren":
  285. this.AppendChildren(edit.m);
  286. break;
  287. case "AssignId":
  288. this.AssignId(edit.path, edit.id);
  289. break;
  290. case "CreatePlaceholder":
  291. this.CreatePlaceholder(edit.id);
  292. break;
  293. case "CreateTextNode":
  294. this.CreateTextNode(edit.value);
  295. break;
  296. case "HydrateText":
  297. this.HydrateText(edit.path, edit.value, edit.id);
  298. break;
  299. case "LoadTemplate":
  300. this.LoadTemplate(edit.name, edit.index, edit.id);
  301. break;
  302. case "PushRoot":
  303. this.PushRoot(edit.id);
  304. break;
  305. case "ReplaceWith":
  306. this.ReplaceWith(edit.id, edit.m);
  307. break;
  308. case "ReplacePlaceholder":
  309. this.ReplacePlaceholder(edit.path, edit.m);
  310. break;
  311. case "InsertAfter":
  312. this.InsertAfter(edit.id, edit.m);
  313. break;
  314. case "InsertBefore":
  315. this.InsertBefore(edit.id, edit.m);
  316. break;
  317. case "Remove":
  318. this.Remove(edit.id);
  319. break;
  320. case "SetText":
  321. this.SetText(edit.id, edit.value);
  322. break;
  323. case "SetAttribute":
  324. this.SetAttribute(edit.id, edit.name, edit.value, edit.ns);
  325. break;
  326. case "RemoveAttribute":
  327. this.RemoveAttribute(edit.id, edit.name, edit.ns);
  328. break;
  329. case "RemoveEventListener":
  330. this.RemoveEventListener(edit.id, edit.name);
  331. break;
  332. case "NewEventListener":
  333. let bubbles = event_bubbles(edit.name);
  334. // this handler is only provided on desktop implementations since this
  335. // method is not used by the web implementation
  336. let handler = (event) => {
  337. let target = event.target;
  338. if (target != null) {
  339. let realId = target.getAttribute(`data-dioxus-id`);
  340. let shouldPreventDefault = target.getAttribute(
  341. `dioxus-prevent-default`
  342. );
  343. if (event.type === "click") {
  344. // todo call prevent default if it's the right type of event
  345. if (shouldPreventDefault !== `onclick`) {
  346. if (target.tagName === "A") {
  347. event.preventDefault();
  348. const href = target.getAttribute("href");
  349. if (href !== "" && href !== null && href !== undefined) {
  350. window.ipc.postMessage(
  351. serializeIpcMessage("browser_open", { href })
  352. );
  353. }
  354. }
  355. }
  356. // also prevent buttons from submitting
  357. if (target.tagName === "BUTTON" && event.type == "submit") {
  358. event.preventDefault();
  359. }
  360. }
  361. // walk the tree to find the real element
  362. while (realId == null) {
  363. // we've reached the root we don't want to send an event
  364. if (target.parentElement === null) {
  365. return;
  366. }
  367. target = target.parentElement;
  368. realId = target.getAttribute(`data-dioxus-id`);
  369. }
  370. shouldPreventDefault = target.getAttribute(
  371. `dioxus-prevent-default`
  372. );
  373. let contents = serialize_event(event);
  374. if (shouldPreventDefault === `on${event.type}`) {
  375. event.preventDefault();
  376. }
  377. if (event.type === "submit") {
  378. event.preventDefault();
  379. }
  380. if (
  381. target.tagName === "FORM" &&
  382. (event.type === "submit" || event.type === "input")
  383. ) {
  384. for (let x = 0; x < target.elements.length; x++) {
  385. let element = target.elements[x];
  386. let name = element.getAttribute("name");
  387. if (name != null) {
  388. if (element.getAttribute("type") === "checkbox") {
  389. // @ts-ignore
  390. contents.values[name] = element.checked ? "true" : "false";
  391. } else if (element.getAttribute("type") === "radio") {
  392. if (element.checked) {
  393. contents.values[name] = element.value;
  394. }
  395. } else {
  396. // @ts-ignore
  397. contents.values[name] =
  398. element.value ?? element.textContent;
  399. }
  400. }
  401. }
  402. }
  403. if (realId === null) {
  404. return;
  405. }
  406. window.ipc.postMessage(
  407. serializeIpcMessage("user_event", {
  408. name: edit.name,
  409. element: parseInt(realId),
  410. data: contents,
  411. bubbles,
  412. })
  413. );
  414. }
  415. };
  416. this.NewEventListener(edit.name, edit.id, bubbles, handler);
  417. break;
  418. }
  419. }
  420. }
  421. function get_mouse_data(event) {
  422. const {
  423. altKey,
  424. button,
  425. buttons,
  426. clientX,
  427. clientY,
  428. ctrlKey,
  429. metaKey,
  430. offsetX,
  431. offsetY,
  432. pageX,
  433. pageY,
  434. screenX,
  435. screenY,
  436. shiftKey,
  437. } = event;
  438. return {
  439. alt_key: altKey,
  440. button: button,
  441. buttons: buttons,
  442. client_x: clientX,
  443. client_y: clientY,
  444. ctrl_key: ctrlKey,
  445. meta_key: metaKey,
  446. offset_x: offsetX,
  447. offset_y: offsetY,
  448. page_x: pageX,
  449. page_y: pageY,
  450. screen_x: screenX,
  451. screen_y: screenY,
  452. shift_key: shiftKey,
  453. };
  454. }
  455. function serialize_event(event) {
  456. switch (event.type) {
  457. case "copy":
  458. case "cut":
  459. case "past": {
  460. return {};
  461. }
  462. case "compositionend":
  463. case "compositionstart":
  464. case "compositionupdate": {
  465. let { data } = event;
  466. return {
  467. data,
  468. };
  469. }
  470. case "keydown":
  471. case "keypress":
  472. case "keyup": {
  473. let {
  474. charCode,
  475. key,
  476. altKey,
  477. ctrlKey,
  478. metaKey,
  479. keyCode,
  480. shiftKey,
  481. location,
  482. repeat,
  483. which,
  484. code,
  485. } = event;
  486. return {
  487. char_code: charCode,
  488. key: key,
  489. alt_key: altKey,
  490. ctrl_key: ctrlKey,
  491. meta_key: metaKey,
  492. key_code: keyCode,
  493. shift_key: shiftKey,
  494. location: location,
  495. repeat: repeat,
  496. which: which,
  497. code,
  498. };
  499. }
  500. case "focus":
  501. case "blur": {
  502. return {};
  503. }
  504. case "change": {
  505. let target = event.target;
  506. let value;
  507. if (target.type === "checkbox" || target.type === "radio") {
  508. value = target.checked ? "true" : "false";
  509. } else {
  510. value = target.value ?? target.textContent;
  511. }
  512. return {
  513. value: value,
  514. values: {},
  515. };
  516. }
  517. case "input":
  518. case "invalid":
  519. case "reset":
  520. case "submit": {
  521. let target = event.target;
  522. let value = target.value ?? target.textContent;
  523. if (target.type === "checkbox") {
  524. value = target.checked ? "true" : "false";
  525. }
  526. return {
  527. value: value,
  528. values: {},
  529. };
  530. }
  531. case "drag":
  532. case "dragend":
  533. case "dragenter":
  534. case "dragexit":
  535. case "dragleave":
  536. case "dragover":
  537. case "dragstart":
  538. case "drop": {
  539. return { mouse: get_mouse_data(event) };
  540. }
  541. case "click":
  542. case "contextmenu":
  543. case "doubleclick":
  544. case "dblclick":
  545. case "mousedown":
  546. case "mouseenter":
  547. case "mouseleave":
  548. case "mousemove":
  549. case "mouseout":
  550. case "mouseover":
  551. case "mouseup": {
  552. return get_mouse_data(event);
  553. }
  554. case "pointerdown":
  555. case "pointermove":
  556. case "pointerup":
  557. case "pointercancel":
  558. case "gotpointercapture":
  559. case "lostpointercapture":
  560. case "pointerenter":
  561. case "pointerleave":
  562. case "pointerover":
  563. case "pointerout": {
  564. const {
  565. altKey,
  566. button,
  567. buttons,
  568. clientX,
  569. clientY,
  570. ctrlKey,
  571. metaKey,
  572. pageX,
  573. pageY,
  574. screenX,
  575. screenY,
  576. shiftKey,
  577. pointerId,
  578. width,
  579. height,
  580. pressure,
  581. tangentialPressure,
  582. tiltX,
  583. tiltY,
  584. twist,
  585. pointerType,
  586. isPrimary,
  587. } = event;
  588. return {
  589. alt_key: altKey,
  590. button: button,
  591. buttons: buttons,
  592. client_x: clientX,
  593. client_y: clientY,
  594. ctrl_key: ctrlKey,
  595. meta_key: metaKey,
  596. page_x: pageX,
  597. page_y: pageY,
  598. screen_x: screenX,
  599. screen_y: screenY,
  600. shift_key: shiftKey,
  601. pointer_id: pointerId,
  602. width: width,
  603. height: height,
  604. pressure: pressure,
  605. tangential_pressure: tangentialPressure,
  606. tilt_x: tiltX,
  607. tilt_y: tiltY,
  608. twist: twist,
  609. pointer_type: pointerType,
  610. is_primary: isPrimary,
  611. };
  612. }
  613. case "select": {
  614. return {};
  615. }
  616. case "touchcancel":
  617. case "touchend":
  618. case "touchmove":
  619. case "touchstart": {
  620. const { altKey, ctrlKey, metaKey, shiftKey } = event;
  621. return {
  622. // changed_touches: event.changedTouches,
  623. // target_touches: event.targetTouches,
  624. // touches: event.touches,
  625. alt_key: altKey,
  626. ctrl_key: ctrlKey,
  627. meta_key: metaKey,
  628. shift_key: shiftKey,
  629. };
  630. }
  631. case "scroll": {
  632. return {};
  633. }
  634. case "wheel": {
  635. const { deltaX, deltaY, deltaZ, deltaMode } = event;
  636. return {
  637. delta_x: deltaX,
  638. delta_y: deltaY,
  639. delta_z: deltaZ,
  640. delta_mode: deltaMode,
  641. };
  642. }
  643. case "animationstart":
  644. case "animationend":
  645. case "animationiteration": {
  646. const { animationName, elapsedTime, pseudoElement } = event;
  647. return {
  648. animation_name: animationName,
  649. elapsed_time: elapsedTime,
  650. pseudo_element: pseudoElement,
  651. };
  652. }
  653. case "transitionend": {
  654. const { propertyName, elapsedTime, pseudoElement } = event;
  655. return {
  656. property_name: propertyName,
  657. elapsed_time: elapsedTime,
  658. pseudo_element: pseudoElement,
  659. };
  660. }
  661. case "abort":
  662. case "canplay":
  663. case "canplaythrough":
  664. case "durationchange":
  665. case "emptied":
  666. case "encrypted":
  667. case "ended":
  668. case "error":
  669. case "loadeddata":
  670. case "loadedmetadata":
  671. case "loadstart":
  672. case "pause":
  673. case "play":
  674. case "playing":
  675. case "progress":
  676. case "ratechange":
  677. case "seeked":
  678. case "seeking":
  679. case "stalled":
  680. case "suspend":
  681. case "timeupdate":
  682. case "volumechange":
  683. case "waiting": {
  684. return {};
  685. }
  686. case "toggle": {
  687. return {};
  688. }
  689. default: {
  690. return {};
  691. }
  692. }
  693. }
  694. function serializeIpcMessage(method, params = {}) {
  695. return JSON.stringify({ method, params });
  696. }
  697. const bool_attrs = {
  698. allowfullscreen: true,
  699. allowpaymentrequest: true,
  700. async: true,
  701. autofocus: true,
  702. autoplay: true,
  703. checked: true,
  704. controls: true,
  705. default: true,
  706. defer: true,
  707. disabled: true,
  708. formnovalidate: true,
  709. hidden: true,
  710. ismap: true,
  711. itemscope: true,
  712. loop: true,
  713. multiple: true,
  714. muted: true,
  715. nomodule: true,
  716. novalidate: true,
  717. open: true,
  718. playsinline: true,
  719. readonly: true,
  720. required: true,
  721. reversed: true,
  722. selected: true,
  723. truespeed: true,
  724. };
  725. function is_element_node(node) {
  726. return node.nodeType == 1;
  727. }
  728. function event_bubbles(event) {
  729. switch (event) {
  730. case "copy":
  731. return true;
  732. case "cut":
  733. return true;
  734. case "paste":
  735. return true;
  736. case "compositionend":
  737. return true;
  738. case "compositionstart":
  739. return true;
  740. case "compositionupdate":
  741. return true;
  742. case "keydown":
  743. return true;
  744. case "keypress":
  745. return true;
  746. case "keyup":
  747. return true;
  748. case "focus":
  749. return false;
  750. case "focusout":
  751. return true;
  752. case "focusin":
  753. return true;
  754. case "blur":
  755. return false;
  756. case "change":
  757. return true;
  758. case "input":
  759. return true;
  760. case "invalid":
  761. return true;
  762. case "reset":
  763. return true;
  764. case "submit":
  765. return true;
  766. case "click":
  767. return true;
  768. case "contextmenu":
  769. return true;
  770. case "doubleclick":
  771. return true;
  772. case "dblclick":
  773. return true;
  774. case "drag":
  775. return true;
  776. case "dragend":
  777. return true;
  778. case "dragenter":
  779. return false;
  780. case "dragexit":
  781. return false;
  782. case "dragleave":
  783. return true;
  784. case "dragover":
  785. return true;
  786. case "dragstart":
  787. return true;
  788. case "drop":
  789. return true;
  790. case "mousedown":
  791. return true;
  792. case "mouseenter":
  793. return false;
  794. case "mouseleave":
  795. return false;
  796. case "mousemove":
  797. return true;
  798. case "mouseout":
  799. return true;
  800. case "scroll":
  801. return false;
  802. case "mouseover":
  803. return true;
  804. case "mouseup":
  805. return true;
  806. case "pointerdown":
  807. return true;
  808. case "pointermove":
  809. return true;
  810. case "pointerup":
  811. return true;
  812. case "pointercancel":
  813. return true;
  814. case "gotpointercapture":
  815. return true;
  816. case "lostpointercapture":
  817. return true;
  818. case "pointerenter":
  819. return false;
  820. case "pointerleave":
  821. return false;
  822. case "pointerover":
  823. return true;
  824. case "pointerout":
  825. return true;
  826. case "select":
  827. return true;
  828. case "touchcancel":
  829. return true;
  830. case "touchend":
  831. return true;
  832. case "touchmove":
  833. return true;
  834. case "touchstart":
  835. return true;
  836. case "wheel":
  837. return true;
  838. case "abort":
  839. return false;
  840. case "canplay":
  841. return false;
  842. case "canplaythrough":
  843. return false;
  844. case "durationchange":
  845. return false;
  846. case "emptied":
  847. return false;
  848. case "encrypted":
  849. return true;
  850. case "ended":
  851. return false;
  852. case "error":
  853. return false;
  854. case "loadeddata":
  855. return false;
  856. case "loadedmetadata":
  857. return false;
  858. case "loadstart":
  859. return false;
  860. case "pause":
  861. return false;
  862. case "play":
  863. return false;
  864. case "playing":
  865. return false;
  866. case "progress":
  867. return false;
  868. case "ratechange":
  869. return false;
  870. case "seeked":
  871. return false;
  872. case "seeking":
  873. return false;
  874. case "stalled":
  875. return false;
  876. case "suspend":
  877. return false;
  878. case "timeupdate":
  879. return false;
  880. case "volumechange":
  881. return false;
  882. case "waiting":
  883. return false;
  884. case "animationstart":
  885. return true;
  886. case "animationend":
  887. return true;
  888. case "animationiteration":
  889. return true;
  890. case "transitionend":
  891. return true;
  892. case "toggle":
  893. return true;
  894. }
  895. return true;
  896. }