@amarajs/plugin-dom
Version:
Provides virtual DOM for AmaraJS web applications.
2 lines • 10.7 kB
JavaScript
!function(l,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):l.AmaraDOM=n()}(this,function(){function l(l){return l&&"VirtualNode"===l.type&&l.version===g}function n(l){return l&&"Widget"===l.type}function e(l){return l&&"Thunk"===l.type}function t(l){return l&&("function"==typeof l.hook&&!l.hasOwnProperty("hook")||"function"==typeof l.unhook&&!l.hasOwnProperty("unhook"))}function r(l,n,e,t,r){this.tagName=l,this.properties=n||x,this.children=e||T,this.key=null!=t?String(t):void 0,this.namespace="string"==typeof r?r:null;var u,a=e&&e.length||0,i=0,o=!1,s=!1,c=!1;for(var d in n)if(n.hasOwnProperty(d)){var p=n[d];b(p)&&p.unhook&&(u||(u={}),u[d]=p)}for(var h=0;h<a;h++){var m=e[h];y(m)?(i+=m.count||0,!o&&m.hasWidgets&&(o=!0),!s&&m.hasThunks&&(s=!0),c||!m.hooks&&!m.descendantHooks||(c=!0)):!o&&v(m)?"function"==typeof m.destroy&&(o=!0):!s&&k(m)&&(s=!0)}this.count=a+i,this.hasWidgets=o,this.hasThunks=s,this.hooks=u,this.descendantHooks=c}function u(l){this.text=String(l)}function a(l,n){if(!l)return i(document.createTextNode(""));if("string"==typeof l){if(!("DOMParser"in window))throw new Error("DOMParser is not available, so parsing string to DOM node is not possible.");C=C||new DOMParser;var e=C.parseFromString(l,"text/html");l=e.body.firstChild?e.getElementsByTagName("body")[0].firstChild:e.head.firstChild&&("TITLE"!==e.head.firstChild.tagName||e.title)?e.head.firstChild:e.firstChild&&"HTML"!==e.firstChild.tagName?e.firstChild:document.createTextNode("")}if("object"!=typeof l||!l||!l.nodeType)throw new Error("invalid dom node",l);return i(l,n)}function i(l,n){return 3===l.nodeType?o(l):1===l.nodeType||9===l.nodeType?s(l,n):new M("")}function o(l){return new M(l.nodeValue)}function s(l,n){var e=l.namespaceURI!==P?l.namespaceURI:null,t=n&&l.getAttribute(n)?l.getAttribute(n):null;return new w(l.tagName,d(l),c(l,n),t,e)}function c(l,n){for(var e=[],t=0;t<l.childNodes.length;t++)e.push(i(l.childNodes[t],n));return e}function d(l){var n={};if(!l.hasAttributes())return n;var e;l.namespaceURI&&l.namespaceURI!==P&&(e=l.namespaceURI);for(var t,r=0;r<l.attributes.length;r++)t="style"==l.attributes[r].name?m(l):e?h(l.attributes[r]):p(l.attributes[r]),t.ns?n[t.name]={namespace:t.ns,value:t.value}:t.isAttr?(n.attributes||(n.attributes={}),n.attributes[t.name]=t.value):n[t.name]=t.value;return n}function p(l){var n,e,t;return n=S[l.name]?S[l.name]:l.name,0===n.indexOf("data-")||0===n.indexOf("aria-")?(e=l.value,t=!0):e=l.value,{name:n,value:e,isAttr:t||!1}}function h(l){return{name:l.name,value:l.value,ns:U[l.name]||""}}function m(l){for(var n=l.style,e={},t=0;t<n.length;++t){var r=n.item(t);e[r]=String(n[r]),e[r].indexOf("url")>-1&&(e[r]=e[r].replace(/\"/g,""))}return{name:"style",value:e}}function f(l){var n=l.h,e=l.diff,t=l.patch,r=l.create;return function(){function l(l,a){var i=!1,o=u.get(a),s=n("amara:content",(d=[]).concat.apply(d,l));o?(h=s.children).unshift.apply(h,o.children.filter(R)):(i=!0,o=E(a),(p=s.children).unshift.apply(p,o.children.map(L))),s.tagName=o.tagName,s.properties=o.properties,u.set(a,s);var c=e(o,s);Object.keys(c).length>1?t(a,c):i&&(a.innerHTML=r(s).innerHTML);var d,p,h}var u=new WeakMap;return function(n){switch(n.type){case"core:apply-target-results":n.payload.dom&&n.payload.dom.forEach(l)}}}}var g="2",y=l,v=n,k=e,b=t,w=r,x={},T=[];r.prototype.version=g,r.prototype.type="VirtualNode";var M=u;u.prototype.version=g,u.prototype.type="VirtualText";var C,O={abbr:"abbr",accept:"accept","accept-charset":"acceptCharset",accesskey:"accessKey",action:"action",allowfullscreen:"allowFullScreen",allowtransparency:"allowTransparency",alt:"alt",async:"async",autocomplete:"autoComplete",autofocus:"autoFocus",autoplay:"autoPlay",cellpadding:"cellPadding",cellspacing:"cellSpacing",challenge:"challenge",charset:"charset",checked:"checked",cite:"cite",class:"className",cols:"cols",colspan:"colSpan",command:"command",content:"content",contenteditable:"contentEditable",contextmenu:"contextMenu",controls:"controls",coords:"coords",crossorigin:"crossOrigin",data:"data",datetime:"dateTime",default:"default",defer:"defer",dir:"dir",disabled:"disabled",download:"download",draggable:"draggable",dropzone:"dropzone",enctype:"encType",for:"htmlFor",form:"form",formaction:"formAction",formenctype:"formEncType",formmethod:"formMethod",formnovalidate:"formNoValidate",formtarget:"formTarget",frameBorder:"frameBorder",headers:"headers",height:"height",hidden:"hidden",high:"high",href:"href",hreflang:"hrefLang","http-equiv":"httpEquiv",icon:"icon",id:"id",inputmode:"inputMode",ismap:"isMap",itemid:"itemId",itemprop:"itemProp",itemref:"itemRef",itemscope:"itemScope",itemtype:"itemType",kind:"kind",label:"label",lang:"lang",list:"list",loop:"loop",manifest:"manifest",max:"max",maxlength:"maxLength",media:"media",mediagroup:"mediaGroup",method:"method",min:"min",minlength:"minLength",multiple:"multiple",muted:"muted",name:"name",novalidate:"noValidate",open:"open",optimum:"optimum",pattern:"pattern",ping:"ping",placeholder:"placeholder",poster:"poster",preload:"preload",radiogroup:"radioGroup",readonly:"readOnly",rel:"rel",required:"required",role:"role",rows:"rows",rowspan:"rowSpan",sandbox:"sandbox",scope:"scope",scoped:"scoped",scrolling:"scrolling",seamless:"seamless",selected:"selected",shape:"shape",size:"size",sizes:"sizes",sortable:"sortable",span:"span",spellcheck:"spellCheck",src:"src",srcdoc:"srcDoc",srcset:"srcSet",start:"start",step:"step",style:"style",tabindex:"tabIndex",target:"target",title:"title",translate:"translate",type:"type",typemustmatch:"typeMustMatch",usemap:"useMap",value:"value",width:"width",wmode:"wmode",wrap:"wrap"},S=O,z="http://www.w3.org/1999/xlink",A="http://www.w3.org/XML/1998/namespace",N={about:null,"accent-height":null,accumulate:null,additive:null,"alignment-baseline":null,alphabetic:null,amplitude:null,"arabic-form":null,ascent:null,attributeName:null,attributeType:null,azimuth:null,bandwidth:null,baseFrequency:null,baseProfile:null,"baseline-shift":null,bbox:null,begin:null,bias:null,by:null,calcMode:null,"cap-height":null,class:null,clip:null,"clip-path":null,"clip-rule":null,clipPathUnits:null,color:null,"color-interpolation":null,"color-interpolation-filters":null,"color-profile":null,"color-rendering":null,content:null,contentScriptType:null,contentStyleType:null,cursor:null,cx:null,cy:null,d:null,datatype:null,defaultAction:null,descent:null,diffuseConstant:null,direction:null,display:null,divisor:null,"dominant-baseline":null,dur:null,dx:null,dy:null,edgeMode:null,editable:null,elevation:null,"enable-background":null,end:null,"ev:event":"http://www.w3.org/2001/xml-events",event:null,exponent:null,externalResourcesRequired:null,fill:null,"fill-opacity":null,"fill-rule":null,filter:null,filterRes:null,filterUnits:null,"flood-color":null,"flood-opacity":null,focusHighlight:null,focusable:null,"font-family":null,"font-size":null,"font-size-adjust":null,"font-stretch":null,"font-style":null,"font-variant":null,"font-weight":null,format:null,from:null,fx:null,fy:null,g1:null,g2:null,"glyph-name":null,"glyph-orientation-horizontal":null,"glyph-orientation-vertical":null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:null,height:null,"horiz-adv-x":null,"horiz-origin-x":null,"horiz-origin-y":null,id:null,ideographic:null,"image-rendering":null,in:null,in2:null,initialVisibility:null,intercept:null,k:null,k1:null,k2:null,k3:null,k4:null,kernelMatrix:null,kernelUnitLength:null,kerning:null,keyPoints:null,keySplines:null,keyTimes:null,lang:null,lengthAdjust:null,"letter-spacing":null,"lighting-color":null,limitingConeAngle:null,local:null,"marker-end":null,"marker-mid":null,"marker-start":null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:null,mediaTime:null,method:null,min:null,mode:null,name:null,"nav-down":null,"nav-down-left":null,"nav-down-right":null,"nav-left":null,"nav-next":null,"nav-prev":null,"nav-right":null,"nav-up":null,"nav-up-left":null,"nav-up-right":null,numOctaves:null,observer:null,offset:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,"overline-position":null,"overline-thickness":null,"panose-1":null,path:null,pathLength:null,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,playbackOrder:null,"pointer-events":null,points:null,pointsAtX:null,pointsAtY:null,pointsAtZ:null,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:null,r:null,radius:null,refX:null,refY:null,rel:null,"rendering-intent":null,repeatCount:null,repeatDur:null,requiredExtensions:null,requiredFeatures:null,requiredFonts:null,requiredFormats:null,resource:null,restart:null,result:null,rev:null,role:null,rotate:null,rx:null,ry:null,scale:null,seed:null,"shape-rendering":null,slope:null,snapshotTime:null,spacing:null,specularConstant:null,specularExponent:null,spreadMethod:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,"stop-color":null,"stop-opacity":null,"strikethrough-position":null,"strikethrough-thickness":null,string:null,stroke:null,"stroke-dasharray":null,"stroke-dashoffset":null,"stroke-linecap":null,"stroke-linejoin":null,"stroke-miterlimit":null,"stroke-opacity":null,"stroke-width":null,surfaceScale:null,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:null,tableValues:null,target:null,targetX:null,targetY:null,"text-anchor":null,"text-decoration":null,"text-rendering":null,textLength:null,timelineBegin:null,title:null,to:null,transform:null,transformBehavior:null,type:null,typeof:null,u1:null,u2:null,"underline-position":null,"underline-thickness":null,unicode:null,"unicode-bidi":null,"unicode-range":null,"units-per-em":null,"v-alphabetic":null,"v-hanging":null,"v-ideographic":null,"v-mathematical":null,values:null,version:null,"vert-adv-y":null,"vert-origin-x":null,"vert-origin-y":null,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,"word-spacing":null,"writing-mode":null,x:null,"x-height":null,x1:null,x2:null,xChannelSelector:null,"xlink:actuate":z,"xlink:arcrole":z,"xlink:href":z,"xlink:role":z,"xlink:show":z,"xlink:title":z,"xlink:type":z,"xml:base":A,"xml:id":A,"xml:lang":A,"xml:space":A,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},U=N,P="http://www.w3.org/1999/xhtml",E=a,L=function(l){return l._prev=null,l},R=function(l){return"_prev"in l};return f});
//# sourceMappingURL=amara-plugin-dom.umd.min.js.map