This file contains 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
export default function changeTag(original, tagName){ | |
// Create a replacement tag of the desired type | |
const replacement = document.createElement(tagName) | |
// Grab all of the original's attributes, and pass them to the replacement | |
Array.prototype.forEach.call(original.attributes, ({name, value}) => { | |
replacement.setAttribute(name, value) | |
}) | |
// Persist contents |
This file contains 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
// Determine whether or not we need to run fallback code by testing for `:target` support. | |
var targetSupport = ( function targetSupport(){ | |
var iframe = document.createElement( 'iframe' ); | |
var body = document.getElementsByTagName( 'body' )[ 0 ]; | |
var doc; | |
var outcome; | |
iframe.tabindex = -1; | |
iframe.style.display = 'none'; |
This file contains 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
var animating = false; | |
// Define an animator consisting of optional incoming and outgoing animations. | |
// alwaysAnimate is false unless specified as true: false means an incoming animation will only trigger if an outgoing animation is also in progress. | |
// forcing dontClone to true means the outward animation will use the original element rather than a clone. This could improve performance by recycling elements, but can lead to trouble: clones have the advantage of being stripped of all event listeners. | |
function animator( incoming, outgoing, alwaysAnimate, dontClone ){ | |
// The resulting animator can be applied to any number of components | |
return function animate( x, y, z ){ | |
var config; | |
var parent; |
This file contains 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 muty from 'muty' | |
export default function ui_io(callback = Function.prototype){ | |
const {addEventListener} = EventTarget.prototype | |
const promises = [] | |
const listeners = [] | |
const logs = [] | |
function register(entry){ |
This file contains 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 {addEventListener} = EventTarget.prototype | |
export default function EventListenerListener({ | |
blocking = false, | |
removing = true, | |
visitor = Function.prototype, | |
} = {}){ | |
if(this instanceof EventListenerListener){} | |
else return new EventListenerListener(...arguments) | |
This file contains 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 muties = new Set | |
class Muty extends MutationObserver { | |
observe(){ | |
muties.add(this) | |
super.observe(...arguments) | |
} | |
disconnect(){ |
Amok is a live editing tool for javascript development. It is beyond awesome. It is the future of javascript development.
Mithril is a javascript framework for building brilliant applications.
This simple test case shows how we can use Amok's event handlers to trigger redraws as and when code is dynamically recompiled in the browser. It's a little taste of the awesome to come.
To use this demo:
- Install Amok
- You'll need Node
This file contains 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
// Async generators don't actually work this way: all yields implictly mandate asynchronous (non-synchronously-blocking) resolution under the hood; so in practice it's probably better to be honest and make this unambiguously wasteful & imprecise and have all steps as explicit awaits. 🙄 | |
const KitchenSink = steps(async function * ($){ | |
$.view(v => | |
m('p.counter', $.attrs.value, '!') | |
) | |
yield $.create | |
style({ | |
transition : 'none', |
This file contains 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
customElements.define('life-cycle', class LifeCycle extends HTMLElement { | |
constructor(){ | |
super() | |
} | |
connected(){} | |
connectedCallback(){ | |
this.style.display = 'contents' | |
this.connected(...arguments) |