diff options
author | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2020-02-15 20:47:24 +0100 |
---|---|---|
committer | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2020-02-15 20:47:24 +0100 |
commit | 9e203aa7ee9eb12645c4520ac4baa21236c67e94 (patch) | |
tree | 36859a51dd3908ab8431b544965e1fec6ffb5486 /src/main/resources/META-INF | |
parent | b3a2c48f559d80c6ff3fd676a3a0a28f75645b57 (diff) |
Web: Move the Flow type cast function to its own module.
Change-Id: I572c91e483fdb0a3b9fce4a9315b9dac92f9a31b
Diffstat (limited to 'src/main/resources/META-INF')
-rw-r--r-- | src/main/resources/META-INF/resources/bookmarks/MlkBookmarkSubmissionForm.js | 19 | ||||
-rw-r--r-- | src/main/resources/META-INF/resources/types.js | 10 |
2 files changed, 15 insertions, 14 deletions
diff --git a/src/main/resources/META-INF/resources/bookmarks/MlkBookmarkSubmissionForm.js b/src/main/resources/META-INF/resources/bookmarks/MlkBookmarkSubmissionForm.js index 41892c1..3d8c2e6 100644 --- a/src/main/resources/META-INF/resources/bookmarks/MlkBookmarkSubmissionForm.js +++ b/src/main/resources/META-INF/resources/bookmarks/MlkBookmarkSubmissionForm.js @@ -1,6 +1,7 @@ // @flow import ProgressSpinner from "../web_modules/elix/define/ProgressSpinner.js"; +import { cast } from "../types.js"; const template = document.createElement('template'); template.innerHTML = ` @@ -49,13 +50,13 @@ export class MlkBookmarkSubmissionForm extends HTMLElement { shadow.appendChild(template.content.cloneNode(true)); this.descriptionInput = - this.cast(shadow.getElementById('description-input')); + cast(shadow.getElementById('description-input')); this.titleInput = - this.cast(shadow.getElementById('title-input')); + cast(shadow.getElementById('title-input')); this.uriInput = - this.cast(shadow.getElementById('uri-input')); + cast(shadow.getElementById('uri-input')); this.uriSpinner = - this.cast(shadow.getElementById('uri-spinner')); + cast(shadow.getElementById('uri-spinner')); } static get observedAttributes() { @@ -116,16 +117,6 @@ export class MlkBookmarkSubmissionForm extends HTMLElement { let pageInfo = await r.json(); this.titleInput.value = pageInfo.title; } - - cast/*:: <T>*/(x /*: ?Object*/) /*: T*/ { - if (x === null || x === undefined) { - throw "unexpected null or undefined"; - } else { - /*:: (x: T); */ - return x; - } - } - } customElements.define("mlk-bookmark-submission-form", MlkBookmarkSubmissionForm); diff --git a/src/main/resources/META-INF/resources/types.js b/src/main/resources/META-INF/resources/types.js new file mode 100644 index 0000000..3ea0797 --- /dev/null +++ b/src/main/resources/META-INF/resources/types.js @@ -0,0 +1,10 @@ +// @flow + +export function cast/*:: <T>*/(x /*: ?Object*/) /*: T*/ { + if (x === null || x === undefined) { + throw "unexpected null or undefined"; + } else { + /*:: (x: T); */ + return x; + } +} |