This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // used to retrieve template content | |
| const templates = new Map; | |
| // used to retrieve node updates | |
| const updates = new WeakMap; | |
| // hyperHTML, the nitty gritty | |
| function hyperHTML(chunks, ...interpolations) { | |
| // if the static chunks are unknown |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { | |
| html, | |
| LitElement | |
| } from "https://unpkg.com/@polymer/lit-element@0.6.2/lit-element.js?module"; | |
| const KEYCODE_TAB = 9; | |
| class FocusTrap extends LitElement { | |
| constructor() { | |
| super(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Based on https://hiddedevries.nl/en/blog/2017-01-29-using-javascript-to-trap-focus-in-an-element | |
| import React, { useRef, useEffect } from 'react'; | |
| const KEYCODE_TAB = 9; | |
| function useFocusTrap() { | |
| const elRef = useRef(null); | |
| function handleFocus(e) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Catch(E, callback) { | |
| return function (target, key: string, descriptor: PropertyDescriptor) { | |
| if(descriptor === undefined) { | |
| descriptor = Object.getOwnPropertyDescriptor(target, key); | |
| } | |
| var originalMethod = descriptor.value; | |
| descriptor.value = function () { | |
| try { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (_ => { | |
| const target = document.documentElement; | |
| // config object | |
| const config = { | |
| attributes: true, | |
| attributeOldValue: true, | |
| characterData: true, | |
| characterDataOldValue: true, | |
| childList: true, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // use JSX with el instead of React.createElement | |
| /** @jsx createElement */ | |
| const Children = { | |
| only(children) { | |
| if (children.length > 1 || children.length === 0) { | |
| throw new Error('The children must have only one element'); | |
| } | |
| return children[0]; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const rafPromise = _ => new Promise(r => requestAnimationFrame(r)); | |
| const transEndPromise = ele => new Promise(r => { | |
| ele.addEventListener('transitionend', function f() { | |
| ele.removeEventListener('transitionend', f); | |
| r(); | |
| }); | |
| }); | |
| const animate = (ele, styles) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Semver = { | |
| let checkVersion = (a, b) => { | |
| let x = String.index(a, '.'); | |
| let y = String.index(b, '.'); | |
| let _b = x > y ? String.concat(String.make(x - y, '0'), [b]) : b; | |
| let _a = y > x ? String.concat(String.make(y - x, '0'), [a]) : a; | |
| let cmp = String.compare(_a, _b); | |
| if (cmp == 0) { | |
| 0; | |
| } else if (cmp > 0) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Ember from 'ember'; | |
| const { Logger: { assert } , tryInvoke } = Ember; | |
| const PromiseProxy = Ember.Object.extend(Ember.PromiseProxyMixin); | |
| const isPromise = (p) => typeof p === 'object' && p !== null && typeof p.then === 'function'; | |
| export default Ember.Component.extend({ | |
| tagName: 'button', | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Ember from 'ember'; | |
| export default Ember.Component.extend({ | |
| classNames: [ 'delete-blog' ], | |
| sudoDeferred: null, | |
| isDone: false, | |
| isWorking: false, | |
| message: null, | |