Skip to content

Instantly share code, notes, and snippets.

@refractalize
Created July 21, 2016 11:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save refractalize/87b6bc03e79c89f3d19135d216ddb8b1 to your computer and use it in GitHub Desktop.
Save refractalize/87b6bc03e79c89f3d19135d216ddb8b1 to your computer and use it in GitHub Desktop.
requirebin sketch
var plastiq = require('plastiq');
var h = plastiq.html;
var model = {value: "1"};
function render() {
return h('div',
model.value == "1"? h('h1', 'you have selected 1'): undefined,
h('label',
'One',
h('input', {type: 'radio', name: 'something', binding: [model, 'value'], value: '1'})
),
h('label',
'Two',
h('input', {type: 'radio', name: 'something', binding: [model, 'value'], value: '2'})
)
);
}
plastiq.append(document.body, render);
setTimeout(function(){require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){},{}],2:[function(require,module,exports){var vtext=require("virtual-dom/vnode/vtext.js");var version=require("virtual-dom/vnode/version");function addChild(children,child){if(child instanceof Array){for(var n=0;n<child.length;n++){addChild(children,child[n])}}else if(child===undefined||child===null){}else if(typeof child!="object"){children.push(new vtext(String(child)))}else if(child instanceof Date){children.push(new vtext(String(child)))}else if(child instanceof Error){children.push(new vtext(child.toString()))}else if(isChild(child)){children.push(child)}else{children.push(new vtext(JSON.stringify(child)))}}module.exports=function(child){var children=[];addChild(children,child);return children};function isChild(x){var type=x.type;if(type=="VirtualNode"||type=="VirtualText"){return x.version==version}else if(type=="Widget"||type=="Thunk"){return true}}},{"virtual-dom/vnode/version":27,"virtual-dom/vnode/vtext.js":30}],3:[function(require,module,exports){var h=require("./rendering").html;var VText=require("virtual-dom/vnode/vtext.js");var domComponent=require("./domComponent");function ComponentWidget(state,vdom){if(!vdom){throw new Error("plastiq.html.component([options], vdom) expects a vdom argument")}this.state=state;this.key=state.key;if(typeof vdom==="function"){this.render=function(){if(h.currentRender){h.currentRender.eventHandlerWrapper=state.on}return vdom.apply(this.state,arguments)};this.canRefresh=true}else{vdom=vdom||new VText("");this.render=function(){return vdom}}this.cacheKey=state.cacheKey;this.component=domComponent();var renderFinished=h.currentRender&&h.currentRender.finished;if(renderFinished){this.afterRender=function(fn){renderFinished.then(fn)}}else{this.afterRender=function(){}}}ComponentWidget.prototype.type="Widget";ComponentWidget.prototype.init=function(){var self=this;if(self.state.onbeforeadd){self.state.onbeforeadd()}var vdom=this.render(this);if(vdom instanceof Array){throw new Error("vdom returned from component cannot be an array")}var element=this.component.create(vdom);if(self.state.onadd){this.afterRender(function(){self.state.onadd(element)})}if(self.state.detached){return document.createTextNode("")}else{return element}};ComponentWidget.prototype.update=function(previous){var self=this;var refresh=!this.cacheKey||this.cacheKey!==previous.cacheKey;if(refresh){if(self.state.onupdate){this.afterRender(function(){self.state.onupdate(self.component.element)})}}this.component=previous.component;if(previous.state&&this.state){var keys=Object.keys(this.state);for(var n=0;n<keys.length;n++){var key=keys[n];previous.state[key]=self.state[key]}this.state=previous.state}if(refresh){var element=this.component.update(this.render(this));if(self.state.detached){return document.createTextNode("")}else{return element}}};ComponentWidget.prototype.refresh=function(){this.component.update(this.render(this));if(this.state.onupdate){this.state.onupdate(this.component.element)}};ComponentWidget.prototype.destroy=function(element){var self=this;if(self.state.onremove){this.afterRender(function(){self.state.onremove(element)})}this.component.destroy()};module.exports=function(state,vdom){if(typeof state==="function"){return new ComponentWidget({},state)}else if(state.constructor===Object){return new ComponentWidget(state,vdom)}else{return new ComponentWidget({},state)}};module.exports.ComponentWidget=ComponentWidget},{"./domComponent":4,"./rendering":34,"virtual-dom/vnode/vtext.js":30}],4:[function(require,module,exports){var createElement=require("virtual-dom/create-element");var diff=require("virtual-dom/diff");var patch=require("virtual-dom/patch");var isVnode=require("virtual-dom/vnode/is-vnode");var isWidget=require("virtual-dom/vnode/is-widget");function DomComponent(options){this.document=options&&options.document}DomComponent.prototype.create=function(vdom){if(!isVnode(vdom)&&!isWidget(vdom)){throw new Error("expected render to return vdom")}this.vdom=vdom;return this.element=createElement(this.vdom,{document:this.document})};DomComponent.prototype.merge=function(vdom,element){if(!isVnode(vdom)&&!isWidget(vdom)){throw new Error("expected render to return vdom")}this.vdom=vdom;return this.element=element};DomComponent.prototype.update=function(vdom){var patches=diff(this.vdom,vdom);this.element=patch(this.element,patches);this.vdom=vdom;return this.element};DomComponent.prototype.destroy=function(options){function destroyWidgets(vdom){if(vdom.type==="Widget"){vdom.destroy()}else if(vdom.children){vdom.children.forEach(destroyWidgets)}}destroyWidgets(this.vdom);if(options&&options.removeElement&&this.element.parentNode){this.element.parentNode.removeChild(this.element)}};function domComponent(options){return new DomComponent(options)}module.exports=domComponent},{"virtual-dom/create-element":6,"virtual-dom/diff":7,"virtual-dom/patch":12,"virtual-dom/vnode/is-vnode":24,"virtual-dom/vnode/is-widget":26}],5:[function(require,module,exports){module.exports=function(model,property){var plastiqMeta=model._plastiqMeta;if(!plastiqMeta){plastiqMeta={};Object.defineProperty(model,"_plastiqMeta",{value:plastiqMeta})}var meta=plastiqMeta[property];if(!meta){meta=plastiqMeta[property]={}}return meta}},{}],6:[function(require,module,exports){var createElement=require("./vdom/create-element.js");module.exports=createElement},{"./vdom/create-element.js":14}],7:[function(require,module,exports){var diff=require("./vtree/diff.js");module.exports=diff},{"./vtree/diff.js":32}],8:[function(require,module,exports){module.exports=function split(undef){var nativeSplit=String.prototype.split,compliantExecNpcg=/()??/.exec("")[1]===undef,self;self=function(str,separator,limit){if(Object.prototype.toString.call(separator)!=="[object RegExp]"){return nativeSplit.call(str,separator,limit)}var output=[],flags=(separator.ignoreCase?"i":"")+(separator.multiline?"m":"")+(separator.extended?"x":"")+(separator.sticky?"y":""),lastLastIndex=0,separator=new RegExp(separator.source,flags+"g"),separator2,match,lastIndex,lastLength;str+="";if(!compliantExecNpcg){separator2=new RegExp("^"+separator.source+"$(?!\\s)",flags)}limit=limit===undef?-1>>>0:limit>>>0;while(match=separator.exec(str)){lastIndex=match.index+match[0].length;if(lastIndex>lastLastIndex){output.push(str.slice(lastLastIndex,match.index));if(!compliantExecNpcg&&match.length>1){match[0].replace(separator2,function(){for(var i=1;i<arguments.length-2;i++){if(arguments[i]===undef){match[i]=undef}}})}if(match.length>1&&match.index<str.length){Array.prototype.push.apply(output,match.slice(1))}lastLength=match[0].length;lastLastIndex=lastIndex;if(output.length>=limit){break}}if(separator.lastIndex===match.index){separator.lastIndex++}}if(lastLastIndex===str.length){if(lastLength||!separator.test("")){output.push("")}}else{output.push(str.slice(lastLastIndex))}return output.length>limit?output.slice(0,limit):output};return self}()},{}],9:[function(require,module,exports){(function(global){var topLevel=typeof global!=="undefined"?global:typeof window!=="undefined"?window:{};var minDoc=require("min-document");if(typeof document!=="undefined"){module.exports=document}else{var doccy=topLevel["__GLOBAL_DOCUMENT_CACHE@4"];if(!doccy){doccy=topLevel["__GLOBAL_DOCUMENT_CACHE@4"]=minDoc}module.exports=doccy}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"min-document":1}],10:[function(require,module,exports){"use strict";module.exports=function isObject(x){return typeof x==="object"&&x!==null}},{}],11:[function(require,module,exports){var nativeIsArray=Array.isArray;var toString=Object.prototype.toString;module.exports=nativeIsArray||isArray;function isArray(obj){return toString.call(obj)==="[object Array]"}},{}],12:[function(require,module,exports){var patch=require("./vdom/patch.js");module.exports=patch},{"./vdom/patch.js":17}],13:[function(require,module,exports){var isObject=require("is-object");var isHook=require("../vnode/is-vhook.js");module.exports=applyProperties;function applyProperties(node,props,previous){for(var propName in props){var propValue=props[propName];if(propValue===undefined){removeProperty(node,propName,propValue,previous)}else if(isHook(propValue)){removeProperty(node,propName,propValue,previous);if(propValue.hook){propValue.hook(node,propName,previous?previous[propName]:undefined)}}else{if(isObject(propValue)){patchObject(node,props,previous,propName,propValue)}else{node[propName]=propValue}}}}function removeProperty(node,propName,propValue,previous){if(previous){var previousValue=previous[propName];if(!isHook(previousValue)){if(propName==="attributes"){for(var attrName in previousValue){node.removeAttribute(attrName)}}else if(propName==="style"){for(var i in previousValue){node.style[i]=""}}else if(typeof previousValue==="string"){node[propName]=""}else{node[propName]=null}}else if(previousValue.unhook){previousValue.unhook(node,propName,propValue)}}}function patchObject(node,props,previous,propName,propValue){var previousValue=previous?previous[propName]:undefined;if(propName==="attributes"){for(var attrName in propValue){var attrValue=propValue[attrName];if(attrValue===undefined){node.removeAttribute(attrName)}else{node.setAttribute(attrName,attrValue)}}return}if(previousValue&&isObject(previousValue)&&getPrototype(previousValue)!==getPrototype(propValue)){node[propName]=propValue;return}if(!isObject(node[propName])){node[propName]={}}var replacer=propName==="style"?"":undefined;for(var k in propValue){var value=propValue[k];node[propName][k]=value===undefined?replacer:value}}function getPrototype(value){if(Object.getPrototypeOf){return Object.getPrototypeOf(value)}else if(value.__proto__){return value.__proto__}else if(value.constructor){return value.constructor.prototype}}},{"../vnode/is-vhook.js":23,"is-object":10}],14:[function(require,module,exports){var document=require("global/document");var applyProperties=require("./apply-properties");var isVNode=require("../vnode/is-vnode.js");var isVText=require("../vnode/is-vtext.js");var isWidget=require("../vnode/is-widget.js");var handleThunk=require("../vnode/handle-thunk.js");module.exports=createElement;function createElement(vnode,opts){var doc=opts?opts.document||document:document;var warn=opts?opts.warn:null;vnode=handleThunk(vnode).a;if(isWidget(vnode)){return vnode.init()}else if(isVText(vnode)){return doc.createTextNode(vnode.text)}else if(!isVNode(vnode)){if(warn){warn("Item is not a valid virtual dom node",vnode)}return null}var node=vnode.namespace===null?doc.createElement(vnode.tagName):doc.createElementNS(vnode.namespace,vnode.tagName);var props=vnode.properties;applyProperties(node,props);var children=vnode.children;for(var i=0;i<children.length;i++){var childNode=createElement(children[i],opts);if(childNode){node.appendChild(childNode)}}return node}},{"../vnode/handle-thunk.js":21,"../vnode/is-vnode.js":24,"../vnode/is-vtext.js":25,"../vnode/is-widget.js":26,"./apply-properties":13,"global/document":9}],15:[function(require,module,exports){var noChild={};module.exports=domIndex;function domIndex(rootNode,tree,indices,nodes){if(!indices||indices.length===0){return{}}else{indices.sort(ascending);return recurse(rootNode,tree,indices,nodes,0)}}function recurse(rootNode,tree,indices,nodes,rootIndex){nodes=nodes||{};if(rootNode){if(indexInRange(indices,rootIndex,rootIndex)){nodes[rootIndex]=rootNode}var vChildren=tree.children;if(vChildren){var childNodes=rootNode.childNodes;for(var i=0;i<tree.children.length;i++){rootIndex+=1;var vChild=vChildren[i]||noChild;var nextIndex=rootIndex+(vChild.count||0);if(indexInRange(indices,rootIndex,nextIndex)){recurse(childNodes[i],vChild,indices,nodes,rootIndex)}rootIndex=nextIndex}}}return nodes}function indexInRange(indices,left,right){if(indices.length===0){return false}var minIndex=0;var maxIndex=indices.length-1;var currentIndex;var currentItem;while(minIndex<=maxIndex){currentIndex=(maxIndex+minIndex)/2>>0;currentItem=indices[currentIndex];if(minIndex===maxIndex){return currentItem>=left&&currentItem<=right}else if(currentItem<left){minIndex=currentIndex+1}else if(currentItem>right){maxIndex=currentIndex-1}else{return true}}return false}function ascending(a,b){return a>b?1:-1}},{}],16:[function(require,module,exports){var applyProperties=require("./apply-properties");var isWidget=require("../vnode/is-widget.js");var VPatch=require("../vnode/vpatch.js");var updateWidget=require("./update-widget");module.exports=applyPatch;function applyPatch(vpatch,domNode,renderOptions){var type=vpatch.type;var vNode=vpatch.vNode;var patch=vpatch.patch;switch(type){case VPatch.REMOVE:return removeNode(domNode,vNode);case VPatch.INSERT:return insertNode(domNode,patch,renderOptions);case VPatch.VTEXT:return stringPatch(domNode,vNode,patch,renderOptions);case VPatch.WIDGET:return widgetPatch(domNode,vNode,patch,renderOptions);case VPatch.VNODE:return vNodePatch(domNode,vNode,patch,renderOptions);case VPatch.ORDER:reorderChildren(domNode,patch);return domNode;case VPatch.PROPS:applyProperties(domNode,patch,vNode.properties);return domNode;case VPatch.THUNK:return replaceRoot(domNode,renderOptions.patch(domNode,patch,renderOptions));default:return domNode}}function removeNode(domNode,vNode){var parentNode=domNode.parentNode;if(parentNode){parentNode.removeChild(domNode)}destroyWidget(domNode,vNode);return null}function insertNode(parentNode,vNode,renderOptions){var newNode=renderOptions.render(vNode,renderOptions);if(parentNode){parentNode.appendChild(newNode)}return parentNode}function stringPatch(domNode,leftVNode,vText,renderOptions){var newNode;if(domNode.nodeType===3){domNode.replaceData(0,domNode.length,vText.text);newNode=domNode}else{var parentNode=domNode.parentNode;newNode=renderOptions.render(vText,renderOptions);if(parentNode&&newNode!==domNode){parentNode.replaceChild(newNode,domNode)}}return newNode}function widgetPatch(domNode,leftVNode,widget,renderOptions){var updating=updateWidget(leftVNode,widget);var newNode;if(updating){newNode=widget.update(leftVNode,domNode)||domNode}else{newNode=renderOptions.render(widget,renderOptions)}var parentNode=domNode.parentNode;if(parentNode&&newNode!==domNode){parentNode.replaceChild(newNode,domNode)}if(!updating){destroyWidget(domNode,leftVNode)}return newNode}function vNodePatch(domNode,leftVNode,vNode,renderOptions){var parentNode=domNode.parentNode;var newNode=renderOptions.render(vNode,renderOptions);if(parentNode&&newNode!==domNode){parentNode.replaceChild(newNode,domNode)}return newNode}function destroyWidget(domNode,w){if(typeof w.destroy==="function"&&isWidget(w)){w.destroy(domNode)}}function reorderChildren(domNode,moves){var childNodes=domNode.childNodes;var keyMap={};var node;var remove;var insert;for(var i=0;i<moves.removes.length;i++){remove=moves.removes[i];node=childNodes[remove.from];if(remove.key){keyMap[remove.key]=node}domNode.removeChild(node)}var length=childNodes.length;for(var j=0;j<moves.inserts.length;j++){insert=moves.inserts[j];node=keyMap[insert.key];domNode.insertBefore(node,insert.to>=length++?null:childNodes[insert.to])}}function replaceRoot(oldRoot,newRoot){if(oldRoot&&newRoot&&oldRoot!==newRoot&&oldRoot.parentNode){oldRoot.parentNode.replaceChild(newRoot,oldRoot)}return newRoot}},{"../vnode/is-widget.js":26,"../vnode/vpatch.js":29,"./apply-properties":13,"./update-widget":18}],17:[function(require,module,exports){var document=require("global/document");var isArray=require("x-is-array");var render=require("./create-element");var domIndex=require("./dom-index");var patchOp=require("./patch-op");module.exports=patch;function patch(rootNode,patches,renderOptions){renderOptions=renderOptions||{};renderOptions.patch=renderOptions.patch&&renderOptions.patch!==patch?renderOptions.patch:patchRecursive;renderOptions.render=renderOptions.render||render;return renderOptions.patch(rootNode,patches,renderOptions)}function patchRecursive(rootNode,patches,renderOptions){var indices=patchIndices(patches);if(indices.length===0){return rootNode}var index=domIndex(rootNode,patches.a,indices);var ownerDocument=rootNode.ownerDocument;if(!renderOptions.document&&ownerDocument!==document){renderOptions.document=ownerDocument}for(var i=0;i<indices.length;i++){var nodeIndex=indices[i];rootNode=applyPatch(rootNode,index[nodeIndex],patches[nodeIndex],renderOptions)}return rootNode}function applyPatch(rootNode,domNode,patchList,renderOptions){if(!domNode){return rootNode}var newNode;if(isArray(patchList)){for(var i=0;i<patchList.length;i++){newNode=patchOp(patchList[i],domNode,renderOptions);if(domNode===rootNode){rootNode=newNode}}}else{newNode=patchOp(patchList,domNode,renderOptions);if(domNode===rootNode){rootNode=newNode}}return rootNode}function patchIndices(patches){var indices=[];for(var key in patches){if(key!=="a"){indices.push(Number(key))}}return indices}},{"./create-element":14,"./dom-index":15,"./patch-op":16,"global/document":9,"x-is-array":11}],18:[function(require,module,exports){var isWidget=require("../vnode/is-widget.js");module.exports=updateWidget;function updateWidget(a,b){if(isWidget(a)&&isWidget(b)){if("name"in a&&"name"in b){return a.id===b.id}else{return a.init===b.init}}return false}},{"../vnode/is-widget.js":26}],19:[function(require,module,exports){"use strict";module.exports=SoftSetHook;function SoftSetHook(value){if(!(this instanceof SoftSetHook)){return new SoftSetHook(value)}this.value=value}SoftSetHook.prototype.hook=function(node,propertyName){if(node[propertyName]!==this.value){node[propertyName]=this.value}}},{}],20:[function(require,module,exports){"use strict";var split=require("browser-split");var classIdSplit=/([\.#]?[a-zA-Z0-9\u007F-\uFFFF_:-]+)/;var notClassId=/^\.|#/;module.exports=parseTag;function parseTag(tag,props){if(!tag){return"DIV"}var noId=!props.hasOwnProperty("id");var tagParts=split(tag,classIdSplit);var tagName=null;if(notClassId.test(tagParts[1])){tagName="DIV"}var classes,part,type,i;for(i=0;i<tagParts.length;i++){part=tagParts[i];if(!part){continue}type=part.charAt(0);if(!tagName){tagName=part}else if(type==="."){classes=classes||[];classes.push(part.substring(1,part.length))}else if(type==="#"&&noId){props.id=part.substring(1,part.length)}}if(classes){if(props.className){classes.push(props.className)}props.className=classes.join(" ")}return props.namespace?tagName:tagName.toUpperCase()}},{"browser-split":8}],21:[function(require,module,exports){var isVNode=require("./is-vnode");var isVText=require("./is-vtext");var isWidget=require("./is-widget");var isThunk=require("./is-thunk");module.exports=handleThunk;function handleThunk(a,b){var renderedA=a;var renderedB=b;if(isThunk(b)){renderedB=renderThunk(b,a)}if(isThunk(a)){renderedA=renderThunk(a,null)}return{a:renderedA,b:renderedB}}function renderThunk(thunk,previous){var renderedThunk=thunk.vnode;if(!renderedThunk){renderedThunk=thunk.vnode=thunk.render(previous)}if(!(isVNode(renderedThunk)||isVText(renderedThunk)||isWidget(renderedThunk))){throw new Error("thunk did not return a valid node")}return renderedThunk}},{"./is-thunk":22,"./is-vnode":24,"./is-vtext":25,"./is-widget":26}],22:[function(require,module,exports){module.exports=isThunk;function isThunk(t){return t&&t.type==="Thunk"}},{}],23:[function(require,module,exports){module.exports=isHook;function isHook(hook){return hook&&(typeof hook.hook==="function"&&!hook.hasOwnProperty("hook")||typeof hook.unhook==="function"&&!hook.hasOwnProperty("unhook"))}},{}],24:[function(require,module,exports){var version=require("./version");module.exports=isVirtualNode;function isVirtualNode(x){return x&&x.type==="VirtualNode"&&x.version===version}},{"./version":27}],25:[function(require,module,exports){var version=require("./version");module.exports=isVirtualText;function isVirtualText(x){return x&&x.type==="VirtualText"&&x.version===version}},{"./version":27}],26:[function(require,module,exports){module.exports=isWidget;function isWidget(w){return w&&w.type==="Widget"}},{}],27:[function(require,module,exports){module.exports="2"},{}],28:[function(require,module,exports){var version=require("./version");var isVNode=require("./is-vnode");var isWidget=require("./is-widget");var isThunk=require("./is-thunk");var isVHook=require("./is-vhook");module.exports=VirtualNode;var noProperties={};var noChildren=[];function VirtualNode(tagName,properties,children,key,namespace){this.tagName=tagName;this.properties=properties||noProperties;this.children=children||noChildren;this.key=key!=null?String(key):undefined;this.namespace=typeof namespace==="string"?namespace:null;var count=children&&children.length||0;var descendants=0;var hasWidgets=false;var hasThunks=false;var descendantHooks=false;var hooks;for(var propName in properties){if(properties.hasOwnProperty(propName)){var property=properties[propName];if(isVHook(property)&&property.unhook){if(!hooks){hooks={}}hooks[propName]=property}}}for(var i=0;i<count;i++){var child=children[i];if(isVNode(child)){descendants+=child.count||0;if(!hasWidgets&&child.hasWidgets){hasWidgets=true}if(!hasThunks&&child.hasThunks){hasThunks=true}if(!descendantHooks&&(child.hooks||child.descendantHooks)){descendantHooks=true}}else if(!hasWidgets&&isWidget(child)){if(typeof child.destroy==="function"){hasWidgets=true}}else if(!hasThunks&&isThunk(child)){hasThunks=true}}this.count=count+descendants;this.hasWidgets=hasWidgets;this.hasThunks=hasThunks;this.hooks=hooks;this.descendantHooks=descendantHooks}VirtualNode.prototype.version=version;VirtualNode.prototype.type="VirtualNode"},{"./is-thunk":22,"./is-vhook":23,"./is-vnode":24,"./is-widget":26,"./version":27}],29:[function(require,module,exports){var version=require("./version");VirtualPatch.NONE=0;VirtualPatch.VTEXT=1;VirtualPatch.VNODE=2;VirtualPatch.WIDGET=3;VirtualPatch.PROPS=4;VirtualPatch.ORDER=5;VirtualPatch.INSERT=6;VirtualPatch.REMOVE=7;VirtualPatch.THUNK=8;module.exports=VirtualPatch;function VirtualPatch(type,vNode,patch){this.type=Number(type);this.vNode=vNode;this.patch=patch}VirtualPatch.prototype.version=version;VirtualPatch.prototype.type="VirtualPatch"},{"./version":27}],30:[function(require,module,exports){var version=require("./version");module.exports=VirtualText;function VirtualText(text){this.text=String(text)}VirtualText.prototype.version=version;VirtualText.prototype.type="VirtualText"},{"./version":27}],31:[function(require,module,exports){var isObject=require("is-object");var isHook=require("../vnode/is-vhook");module.exports=diffProps;function diffProps(a,b){var diff;for(var aKey in a){if(!(aKey in b)){diff=diff||{};diff[aKey]=undefined}var aValue=a[aKey];var bValue=b[aKey];if(aValue===bValue){continue}else if(isObject(aValue)&&isObject(bValue)){if(getPrototype(bValue)!==getPrototype(aValue)){diff=diff||{};diff[aKey]=bValue}else if(isHook(bValue)){diff=diff||{};diff[aKey]=bValue}else{var objectDiff=diffProps(aValue,bValue);if(objectDiff){diff=diff||{};diff[aKey]=objectDiff}}}else{diff=diff||{};diff[aKey]=bValue}}for(var bKey in b){if(!(bKey in a)){diff=diff||{};diff[bKey]=b[bKey]}}return diff}function getPrototype(value){if(Object.getPrototypeOf){return Object.getPrototypeOf(value)}else if(value.__proto__){return value.__proto__}else if(value.constructor){return value.constructor.prototype}}},{"../vnode/is-vhook":23,"is-object":10}],32:[function(require,module,exports){var isArray=require("x-is-array");var VPatch=require("../vnode/vpatch");var isVNode=require("../vnode/is-vnode");var isVText=require("../vnode/is-vtext");var isWidget=require("../vnode/is-widget");var isThunk=require("../vnode/is-thunk");var handleThunk=require("../vnode/handle-thunk");var diffProps=require("./diff-props");module.exports=diff;function diff(a,b){var patch={a:a};walk(a,b,patch,0);return patch}function walk(a,b,patch,index){if(a===b){return}var apply=patch[index];var applyClear=false;if(isThunk(a)||isThunk(b)){thunks(a,b,patch,index)}else if(b==null){if(!isWidget(a)){clearState(a,patch,index);apply=patch[index]}apply=appendPatch(apply,new VPatch(VPatch.REMOVE,a,b))}else if(isVNode(b)){if(isVNode(a)){if(a.tagName===b.tagName&&a.namespace===b.namespace&&a.key===b.key){var propsPatch=diffProps(a.properties,b.properties);if(propsPatch){apply=appendPatch(apply,new VPatch(VPatch.PROPS,a,propsPatch))}apply=diffChildren(a,b,patch,apply,index)}else{apply=appendPatch(apply,new VPatch(VPatch.VNODE,a,b));applyClear=true}}else{apply=appendPatch(apply,new VPatch(VPatch.VNODE,a,b));applyClear=true}}else if(isVText(b)){if(!isVText(a)){apply=appendPatch(apply,new VPatch(VPatch.VTEXT,a,b));applyClear=true}else if(a.text!==b.text){apply=appendPatch(apply,new VPatch(VPatch.VTEXT,a,b))}}else if(isWidget(b)){if(!isWidget(a)){applyClear=true}apply=appendPatch(apply,new VPatch(VPatch.WIDGET,a,b))}if(apply){patch[index]=apply}if(applyClear){clearState(a,patch,index)}}function diffChildren(a,b,patch,apply,index){var aChildren=a.children;var orderedSet=reorder(aChildren,b.children);var bChildren=orderedSet.children;var aLen=aChildren.length;var bLen=bChildren.length;var len=aLen>bLen?aLen:bLen;for(var i=0;i<len;i++){var leftNode=aChildren[i];var rightNode=bChildren[i];index+=1;if(!leftNode){if(rightNode){apply=appendPatch(apply,new VPatch(VPatch.INSERT,null,rightNode))}}else{walk(leftNode,rightNode,patch,index)}if(isVNode(leftNode)&&leftNode.count){index+=leftNode.count}}if(orderedSet.moves){apply=appendPatch(apply,new VPatch(VPatch.ORDER,a,orderedSet.moves))}return apply}function clearState(vNode,patch,index){unhook(vNode,patch,index);destroyWidgets(vNode,patch,index)}function destroyWidgets(vNode,patch,index){if(isWidget(vNode)){if(typeof vNode.destroy==="function"){patch[index]=appendPatch(patch[index],new VPatch(VPatch.REMOVE,vNode,null))}}else if(isVNode(vNode)&&(vNode.hasWidgets||vNode.hasThunks)){var children=vNode.children;var len=children.length;for(var i=0;i<len;i++){var child=children[i];index+=1;destroyWidgets(child,patch,index);if(isVNode(child)&&child.count){index+=child.count}}}else if(isThunk(vNode)){thunks(vNode,null,patch,index)}}function thunks(a,b,patch,index){var nodes=handleThunk(a,b);var thunkPatch=diff(nodes.a,nodes.b);if(hasPatches(thunkPatch)){patch[index]=new VPatch(VPatch.THUNK,null,thunkPatch)}}function hasPatches(patch){for(var index in patch){if(index!=="a"){return true}}return false}function unhook(vNode,patch,index){if(isVNode(vNode)){if(vNode.hooks){patch[index]=appendPatch(patch[index],new VPatch(VPatch.PROPS,vNode,undefinedKeys(vNode.hooks)))}if(vNode.descendantHooks||vNode.hasThunks){var children=vNode.children;var len=children.length;for(var i=0;i<len;i++){var child=children[i];index+=1;unhook(child,patch,index);if(isVNode(child)&&child.count){index+=child.count}}}}else if(isThunk(vNode)){thunks(vNode,null,patch,index)}}function undefinedKeys(obj){var result={};for(var key in obj){result[key]=undefined}return result}function reorder(aChildren,bChildren){var bChildIndex=keyIndex(bChildren);var bKeys=bChildIndex.keys;var bFree=bChildIndex.free;if(bFree.length===bChildren.length){return{children:bChildren,moves:null}}var aChildIndex=keyIndex(aChildren);var aKeys=aChildIndex.keys;var aFree=aChildIndex.free;if(aFree.length===aChildren.length){return{children:bChildren,moves:null}}var newChildren=[];var freeIndex=0;var freeCount=bFree.length;var deletedItems=0;for(var i=0;i<aChildren.length;i++){var aItem=aChildren[i];var itemIndex;if(aItem.key){if(bKeys.hasOwnProperty(aItem.key)){itemIndex=bKeys[aItem.key];newChildren.push(bChildren[itemIndex])}else{itemIndex=i-deletedItems++;newChildren.push(null)}}else{if(freeIndex<freeCount){itemIndex=bFree[freeIndex++];newChildren.push(bChildren[itemIndex])}else{itemIndex=i-deletedItems++;newChildren.push(null)}}}var lastFreeIndex=freeIndex>=bFree.length?bChildren.length:bFree[freeIndex];for(var j=0;j<bChildren.length;j++){var newItem=bChildren[j];if(newItem.key){if(!aKeys.hasOwnProperty(newItem.key)){newChildren.push(newItem)}}else if(j>=lastFreeIndex){newChildren.push(newItem)}}var simulate=newChildren.slice();var simulateIndex=0;var removes=[];var inserts=[];var simulateItem;for(var k=0;k<bChildren.length;){var wantedItem=bChildren[k];simulateItem=simulate[simulateIndex];while(simulateItem===null&&simulate.length){removes.push(remove(simulate,simulateIndex,null));simulateItem=simulate[simulateIndex]}if(!simulateItem||simulateItem.key!==wantedItem.key){if(wantedItem.key){if(simulateItem&&simulateItem.key){if(bKeys[simulateItem.key]!==k+1){removes.push(remove(simulate,simulateIndex,simulateItem.key));simulateItem=simulate[simulateIndex];if(!simulateItem||simulateItem.key!==wantedItem.key){inserts.push({key:wantedItem.key,to:k})}else{simulateIndex++}}else{inserts.push({key:wantedItem.key,to:k})}}else{inserts.push({key:wantedItem.key,to:k})}k++}else if(simulateItem&&simulateItem.key){removes.push(remove(simulate,simulateIndex,simulateItem.key))}}else{simulateIndex++;k++}}while(simulateIndex<simulate.length){simulateItem=simulate[simulateIndex];removes.push(remove(simulate,simulateIndex,simulateItem&&simulateItem.key))}if(removes.length===deletedItems&&!inserts.length){return{children:newChildren,moves:null}}return{children:newChildren,moves:{removes:removes,inserts:inserts}}}function remove(arr,index,key){arr.splice(index,1);return{from:index,key:key}}function keyIndex(children){var keys={};var free=[];var length=children.length;for(var i=0;i<length;i++){var child=children[i];if(child.key){keys[child.key]=i}else{free.push(i)}}return{keys:keys,free:free}}function appendPatch(apply,patch){if(apply){if(isArray(apply)){apply.push(patch)}else{apply=[apply,patch]}return apply}else{return patch}}},{"../vnode/handle-thunk":21,"../vnode/is-thunk":22,"../vnode/is-vnode":24,"../vnode/is-vtext":25,"../vnode/is-widget":26,"../vnode/vpatch":29,"./diff-props":31,"x-is-array":11}],33:[function(require,module,exports){module.exports=function(obj,prop){console.log("plastiq.bind() will be deprecated in the next release, use [model, 'fieldName'] instead");return{get:function(){return obj[prop]},set:function(value){obj[prop]=value}}}},{}],34:[function(require,module,exports){(function(global){var h=require("./vhtml");var domComponent=require("./domComponent");var simplePromise=require("./simplePromise");var bindingMeta=require("./meta");var coerceChildren=require("./coerceChildren");var parseTag=require("virtual-dom/virtual-hyperscript/parse-tag.js");function doThenFireAfterRender(attachment,fn){try{exports.html.currentRender={attachment:attachment};exports.html.currentRender.finished=simplePromise();exports.html.refresh=function(component){if(isComponent(component)){refreshComponent(component,attachment)}else{attachment.refresh()}};fn()}finally{exports.html.currentRender.finished.fulfill();exports.html.currentRender.finished=undefined;delete exports.html.currentRender;exports.html.refresh=refreshOutOfRender}}function refreshOutOfRender(){throw new Error("Please assign plastiq.html.refresh during a render cycle if you want to use it in event handlers. See https://github.com/featurist/plastiq#refresh-outside-render-cycle")}function areAllComponents(components){for(var i=0;i<components.length;i++){if(!isComponent(components[i])){return false}}return true}function isComponent(component){return component&&typeof component.init==="function"&&typeof component.update==="function"&&typeof component.destroy==="function"}exports.merge=function(element,render,model,options){var attachment=startAttachment(render,model,options,function(render,domComponentOptions){var component=domComponent(domComponentOptions);
exports.html.currentRender.eventHandlerWrapper=function(){return null};var vdom=render();component.merge(vdom,element);return component});attachment.refresh();return attachment};exports.append=function(element,render,model,options){return startAttachment(render,model,options,function(render,domComponentOptions){var component=domComponent(domComponentOptions);var vdom=render();element.appendChild(component.create(vdom));return component})};exports.replace=function(element,render,model,options){return startAttachment(render,model,options,function(render,domComponentOptions){var component=domComponent(domComponentOptions);var vdom=render();element.parentNode.replaceChild(component.create(vdom),element);return component})};exports.appendVDom=function(vdom,render,model,options){return startAttachment(render,model,options,function(render){var component={create:function(newVDom){vdom.children=[];if(newVDom){vdom.children.push(newVDom)}},update:function(newVDom){vdom.children=[];if(newVDom){vdom.children.push(newVDom)}}};component.create(render());return component})};var attachmentId=1;function startAttachment(render,model,options,attachToDom){if(typeof render=="object"&&typeof render.render=="function"){return start(function(){return render.render()},model,attachToDom)}else{return start(function(){return render(model)},options,attachToDom)}}function start(render,options,attachToDom){var win=options&&options.window||window;var requestRender=options&&options.requestRender||win.requestAnimationFrame||win.setTimeout;var requested=false;function refresh(){if(!requested){requestRender(function(){requested=false;if(attachment.attached){doThenFireAfterRender(attachment,function(){var vdom=render();component.update(vdom)})}});requested=true}}var attachment={refresh:refresh,requestRender:requestRender,id:attachmentId++,attached:true};var component;doThenFireAfterRender(attachment,function(){if(options){var domComponentOptions={document:options.document}}component=attachToDom(render,domComponentOptions)});return{detach:function(){attachment.attached=false},remove:function(){component.destroy({removeElement:true});attachment.attached=false},refresh:refresh}}exports.attach=function(){console.warn("plastiq.attach has been renamed to plastiq.append, plastiq.attach will be deprecated in a future version");return exports.append.apply(this,arguments)};function refreshComponent(component,attachment){if(!component.canRefresh){throw new Error("this component cannot be refreshed, make sure that the component's view is returned from a function")}if(!component.requested){var requestRender=attachment.requestRender;requestRender(function(){doThenFireAfterRender(attachment,function(){component.requested=false;component.refresh()})});component.requested=true}}var norefresh={};function refreshify(fn,options){if(!fn){return fn}if(!exports.html.currentRender){if(typeof global==="object"){return fn}else{throw new Error("You cannot create virtual-dom event handlers outside a render function. See https://github.com/featurist/plastiq#outside-render-cycle")}}var onlyRefreshAfterPromise=options&&options.refresh=="promise";var componentToRefresh=options&&options.component;if(options&&(options.norefresh==true||options.refresh==false)){return fn}var attachment=exports.html.currentRender.attachment;var r=attachment.refresh;return function(){var result=fn.apply(this,arguments);function handleResult(result,promiseResult){var allowRefresh=!onlyRefreshAfterPromise||promiseResult;if(allowRefresh&&result&&typeof result=="function"){console.warn("animations are now deprecated, you should consider using plastiq.html.refresh");result(r)}else if(result&&typeof result.then=="function"){if(allowRefresh){r()}result.then(function(result){handleResult(result,onlyRefreshAfterPromise)})}else if(result&&typeof result.init==="function"&&typeof result.update==="function"&&typeof result.destroy==="function"){refreshComponent(result,attachment)}else if(result instanceof Array&&areAllComponents(result)){for(var i=0;i<result.length;i++){refreshComponent(result[i],attachment)}}else if(componentToRefresh){refreshComponent(componentToRefresh,attachment)}else if(result===norefresh){}else if(allowRefresh){r();return result}}return handleResult(result)}}function refreshAfter(promise){var refresh=exports.html.refresh;promise.then(refresh)}function bindTextInput(attributes,children,get,set){var textEventNames=["onkeydown","oninput","onpaste","textInput"];var bindingValue=get();if(!(bindingValue instanceof Error)){attributes.value=bindingValue!=undefined?bindingValue:""}attachEventHandler(attributes,textEventNames,function(ev){if(bindingValue!=ev.target.value){set(ev.target.value)}})}function sequenceFunctions(handler1,handler2){return function(ev){handler1(ev);return handler2(ev)}}function insertEventHandler(attributes,eventName,handler,after){var previousHandler=attributes[eventName];if(previousHandler){if(after){attributes[eventName]=sequenceFunctions(previousHandler,handler)}else{attributes[eventName]=sequenceFunctions(handler,previousHandler)}}else{attributes[eventName]=handler}}function attachEventHandler(attributes,eventNames,handler){if(eventNames instanceof Array){for(var n=0;n<eventNames.length;n++){insertEventHandler(attributes,eventNames[n],handler)}}else{insertEventHandler(attributes,eventNames,handler)}}var inputTypeBindings={text:bindTextInput,textarea:bindTextInput,checkbox:function(attributes,children,get,set){attributes.checked=get();attachEventHandler(attributes,"onclick",function(ev){attributes.checked=ev.target.checked;set(ev.target.checked)})},radio:function(attributes,children,get,set){var value=attributes.value;attributes.checked=get()==attributes.value;attachEventHandler(attributes,"onclick",function(){attributes.checked=true;set(value)})},select:function(attributes,children,get,set){var currentValue=get();var options=children.filter(function(child){return child.tagName.toLowerCase()=="option"});var values=[];var selectedIndex;for(var n=0;n<options.length;n++){var option=options[n];var value=option.properties.value;var text=option.children.map(function(x){return x.text}).join("");values.push(value!=undefined?value:text);var selected=value==currentValue||text==currentValue;if(selected){selectedIndex=n}option.properties.selected=selected;option.properties.value=n}if(selectedIndex!==undefined){attributes.selectedIndex=selectedIndex}attachEventHandler(attributes,"onchange",function(ev){attributes.selectedIndex=ev.target.selectedIndex;set(values[ev.target.value])})},file:function(attributes,children,get,set){var multiple=attributes.multiple;attachEventHandler(attributes,"onchange",function(ev){if(multiple){set(ev.target.files)}else{set(ev.target.files[0])}})}};function bindModel(attributes,children,type){var bind=inputTypeBindings[type]||bindTextInput;var bindingAttr=makeBinding(attributes.binding);bind(attributes,children,bindingAttr.get,bindingAttr.set)}function inputType(selector,attributes){if(/^textarea\b/i.test(selector)){return"textarea"}else if(/^select\b/i.test(selector)){return"select"}else{return attributes.type||"text"}}var renames={"for":"htmlFor","class":"className",contenteditable:"contentEditable",tabindex:"tabIndex",colspan:"colSpan"};var dataAttributeRegex=/^data-/;function prepareAttributes(tag,attributes,childElements){var keys=Object.keys(attributes);var dataset;var eventHandlerWrapper=exports.html.currentRender&&exports.html.currentRender.eventHandlerWrapper;for(var k=0;k<keys.length;k++){var key=keys[k];var attribute=attributes[key];if(typeof attribute=="function"){if(eventHandlerWrapper){var fn=eventHandlerWrapper.call(undefined,key.replace(/^on/,""),attribute);attributes[key]=typeof fn==="function"?refreshify(fn):fn}else{attributes[key]=refreshify(attribute)}}var rename=renames[key];if(rename){attributes[rename]=attribute;delete attributes[key];continue}if(dataAttributeRegex.test(key)){if(!dataset){dataset=attributes.dataset;if(!dataset){dataset=attributes.dataset={}}}var datakey=key.replace(dataAttributeRegex,"");dataset[datakey]=attribute;delete attributes[key];continue}}if(attributes.className){attributes.className=generateClassName(attributes.className)}if(attributes.binding){bindModel(attributes,childElements,inputType(tag,attributes));delete attributes.binding}}exports.html=function(hierarchySelector){var hasHierarchy=hierarchySelector.indexOf(" ")>=0;var selector,selectorElements;if(hasHierarchy){selectorElements=hierarchySelector.match(/\S+/g);selector=selectorElements[selectorElements.length-1]}else{selector=hierarchySelector}var attributes;var childElements;var vdom;var tag;if(arguments[1]&&arguments[1].constructor==Object){attributes=arguments[1];childElements=coerceChildren(Array.prototype.slice.call(arguments,2));prepareAttributes(selector,attributes,childElements);tag=parseTag(selector,attributes);vdom=h(tag,attributes,childElements)}else{attributes={};childElements=coerceChildren(Array.prototype.slice.call(arguments,1));tag=parseTag(selector,attributes);vdom=h(tag,attributes,childElements)}if(hasHierarchy){for(var n=selectorElements.length-2;n>=0;n--){vdom=h(selectorElements[n],{},[vdom])}}return vdom};exports.jsx=function(tag,attributes){var childElements=coerceChildren(Array.prototype.slice.call(arguments,2));if(attributes){prepareAttributes(tag,attributes,childElements)}return h(tag,attributes||{},childElements)};exports.html.refreshify=refreshify;exports.html.refresh=refreshOutOfRender;exports.html.refreshAfter=refreshAfter;exports.html.norefresh=norefresh;function makeBinding(b,options){var binding=b instanceof Array?bindingObject.apply(undefined,b):b;binding.set=refreshify(binding.set,options);return binding}function makeConverter(converter){if(typeof converter=="function"){return{view:function(model){return model},model:function(view){return converter(view)}}}else{return converter}}function chainConverters(startIndex,converters){function makeConverters(){if(!_converters){_converters=new Array(converters.length-startIndex);for(var n=startIndex;n<converters.length;n++){_converters[n-startIndex]=makeConverter(converters[n])}}}if(converters.length-startIndex==1){return makeConverter(converters[startIndex])}else{var _converters;return{view:function(model){makeConverters();var intermediateValue=model;for(var n=0;n<_converters.length;n++){intermediateValue=_converters[n].view(intermediateValue)}return intermediateValue},model:function(view){makeConverters();var intermediateValue=view;for(var n=_converters.length-1;n>=0;n--){intermediateValue=_converters[n].model(intermediateValue)}return intermediateValue}}}}function bindingObject(model,property){var _meta;function plastiqMeta(){return _meta||(_meta=bindingMeta(model,property))}if(arguments.length>2){var converter=chainConverters(2,arguments);return{get:function(){var meta=plastiqMeta();var modelValue=model[property];var modelText;if(meta.error){return meta.view}else if(meta.view===undefined){modelText=converter.view(modelValue);meta.view=modelText;return modelText}else{var previousValue=converter.model(meta.view);modelText=converter.view(modelValue);var normalisedPreviousText=converter.view(previousValue);if(modelText===normalisedPreviousText){return meta.view}else{meta.view=modelText;return modelText}}},set:function(view){var meta=plastiqMeta();meta.view=view;try{model[property]=converter.model(view,model[property]);delete meta.error}catch(e){meta.error=e}},meta:function(){return plastiqMeta()}}}else{return{get:function(){return model[property]},set:function(value){model[property]=value},meta:function(){return plastiqMeta()}}}}exports.binding=makeBinding;exports.html.binding=makeBinding;exports.html.meta=bindingMeta;function rawHtml(){var selector;var html;var options;if(arguments.length==2){selector=arguments[0];html=arguments[1];options={innerHTML:html};return exports.html(selector,options)}else{selector=arguments[0];options=arguments[1];html=arguments[2];options.innerHTML=html;return exports.html(selector,options)}}exports.html.rawHtml=rawHtml;function generateConditionalClassNames(obj){return Object.keys(obj).filter(function(key){return obj[key]}).join(" ")||undefined}function generateClassName(obj){if(typeof obj=="object"){if(obj instanceof Array){var names=obj.map(function(item){return generateClassName(item)});return names.join(" ")||undefined}else{return generateConditionalClassNames(obj)}}else{return obj}}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./coerceChildren":2,"./domComponent":4,"./meta":5,"./simplePromise":35,"./vhtml":36,"virtual-dom/virtual-hyperscript/parse-tag.js":20}],35:[function(require,module,exports){function SimplePromise(){this.listeners=[]}SimplePromise.prototype.fulfill=function(value){if(!this.isFulfilled){this.isFulfilled=true;this.value=value;this.listeners.forEach(function(listener){listener()})}};SimplePromise.prototype.then=function(success){if(this.isFulfilled){var self=this;setTimeout(function(){success(self.value)})}else{this.listeners.push(success)}};module.exports=function(){return new SimplePromise}},{}],36:[function(require,module,exports){"use strict";var VNode=require("virtual-dom/vnode/vnode.js");var isHook=require("virtual-dom/vnode/is-vhook");var softSetHook=require("virtual-dom/virtual-hyperscript/hooks/soft-set-hook.js");module.exports=h;function h(tagName,props,children){var tag=tagName;if(props.hasOwnProperty("key")){var key=props.key;props.key=undefined}if(props.hasOwnProperty("namespace")){var namespace=props.namespace;props.namespace=undefined}if(tag.toLowerCase()==="input"&&!namespace&&props.hasOwnProperty("value")&&props.value!==undefined&&!isHook(props.value)){props.value=softSetHook(props.value)}return new VNode(tag,props,children,key,namespace)}},{"virtual-dom/virtual-hyperscript/hooks/soft-set-hook.js":19,"virtual-dom/vnode/is-vhook":23,"virtual-dom/vnode/vnode.js":28}],37:[function(require,module,exports){var domComponent=require("./domComponent");var rendering=require("./rendering");var VText=require("virtual-dom/vnode/vtext.js");function WindowWidget(attributes){this.attributes=attributes;this.vdom=new VText("");this.component=domComponent();var self=this;this.cache={};Object.keys(this.attributes).forEach(function(key){self.cache[key]=rendering.html.refreshify(self.attributes[key])})}WindowWidget.prototype.type="Widget";WindowWidget.prototype.init=function(){applyPropertyDiffs(window,{},this.attributes,{},this.cache);return this.element=document.createTextNode("")};function uniq(array){var sortedArray=array.slice();sortedArray.sort();var last;for(var n=0;n<sortedArray.length;){var current=sortedArray[n];if(last===current){sortedArray.splice(n,1)}else{n++}last=current}return sortedArray}function applyPropertyDiffs(element,previous,current,previousCache,currentCache){uniq(Object.keys(previous).concat(Object.keys(current))).forEach(function(key){if(/^on/.test(key)){var event=key.slice(2);var prev=previous[key];var curr=current[key];var refreshPrev=previousCache[key];var refreshCurr=currentCache[key];if(prev!==undefined&&curr===undefined){element.removeEventListener(event,refreshPrev)}else if(prev!==undefined&&curr!==undefined&&prev!==curr){element.removeEventListener(event,refreshPrev);element.addEventListener(event,refreshCurr)}else if(prev===undefined&&curr!==undefined){element.addEventListener(event,refreshCurr)}}})}WindowWidget.prototype.update=function(previous){applyPropertyDiffs(window,previous.attributes,this.attributes,previous.cache,this.cache);this.component=previous.component;return this.element};WindowWidget.prototype.destroy=function(){applyPropertyDiffs(window,this.attributes,{},this.cache,{})};module.exports=function(attributes){return new WindowWidget(attributes)}},{"./domComponent":4,"./rendering":34,"virtual-dom/vnode/vtext.js":30}],plastiq:[function(require,module,exports){var rendering=require("./rendering");exports.html=rendering.html;exports.jsx=rendering.jsx;exports.attach=rendering.attach;exports.replace=rendering.replace;exports.append=rendering.append;exports.appendVDom=rendering.appendVDom;exports.merge=rendering.merge;exports.bind=require("./oldbind");exports.binding=rendering.binding;var windowEvents=require("./windowEvents");exports.html.window=function(attributes){return windowEvents(attributes)};exports.html.component=require("./component")},{"./component":3,"./oldbind":33,"./rendering":34,"./windowEvents":37}]},{},[]);var plastiq=require("plastiq");var h=plastiq.html;var model={value:"1"};function render(){return h("div",model.value=="1"?h("h1","you have selected 1"):undefined,h("label","One",h("input",{type:"radio",name:"something",binding:[model,"value"],value:"1"})),h("label","Two",h("input",{type:"radio",name:"something",binding:[model,"value"],value:"2"})))}plastiq.append(document.body,render)},0);
{
"name": "requirebin-sketch",
"version": "1.0.0",
"dependencies": {
"plastiq": "1.30.1"
}
}
<!-- contents of this file will be placed inside the <body> -->
<!-- contents of this file will be placed inside the <head> -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment