UNPKG

@atlassian/aui

Version:

Atlassian User Interface Framework

14 lines 6.76 kB
/*!! * @atlassian/aui - Atlassian User Interface Framework * @version v8.0.0-alpha.1 * @link https://aui.atlassian.com * @license SEE LICENSE IN LICENSE.md * @author Atlassian Pty Ltd. */ exports.ids=[30],exports.modules={18: /*!*****************************************************************************************************************!*\ !*** /Users/cdarroch/work/atlassian/aui-stuff/auinext/node_modules/skatejs-template-html/dist/template-html.js ***! \*****************************************************************************************************************/ /*! no static exports found */ /*! all exports used */ /*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(e,t,n){var r;!function(){"use strict";var o=window.DocumentFragment,i=window.HTMLElement.prototype,a=i.matches||i.msMatchesSelector||i.webkitMatchesSelector||i.mozMatchesSelector||i.oMatchesSelector;function d(e,t){if(e.__SKATE_TEMPLATE_HTML_DATA)return e.__SKATE_TEMPLATE_HTML_DATA[t]}function c(e,t,n){return e.__SKATE_TEMPLATE_HTML_DATA||(e.__SKATE_TEMPLATE_HTML_DATA={}),e.__SKATE_TEMPLATE_HTML_DATA[t]=n,e}function l(e){var t=e.match(/\s*<([^\s>]+)/),n=document.createElement(t&&{caption:"table",dd:"dl",dt:"dl",li:"ul",tbody:"table",td:"tr",thead:"table",tr:"tbody"}[t[1]]||"div");return n.innerHTML=e,s(n.childNodes)}function s(e){for(var t=document.createDocumentFragment();e&&e.length;)t.appendChild(e[0]);return t}function f(e,t){for(var n=[],r=e.nextSibling;r!==t;)n.push(r),r=r.nextSibling;return n}function u(e,t){if(t){for(var n=e.querySelectorAll(t),r=n.length,o=[],i=0;i<r;i++){var a=n[i];a.parentNode===e&&o.push(a)}return o}return[].slice.call(e.childNodes)||[]}function h(e){for(var t=e.defaultNodes,n=t.length,r=0;r<n;r++)e.container.insertBefore(t[r],e.endNode);e.isDefault=!0}function v(e){for(var t=e.defaultNodes,n=t.length,r=0;r<n;r++){var o=t[r];o.parentNode.removeChild(o)}e.isDefault=!1}function p(e,t){return{get:function(){var n=e[t];return"function"==typeof n?n.bind(e):n},set:function(n){e[t]=n}}}function N(e){var t,n=e.textContent.match(/^ (\/?)content (.*)/i);if(n){if(n[2])try{t=JSON.parse(n[2])}catch(t){throw new Error('Unable to parse content comment data: "'+t+'" in "\x3c!--'+e.textContent+'--\x3e".')}return{data:t||{defaultContent:void 0,isDefault:void 0,selector:void 0},type:n[1]?"close":"open"}}}function T(){var e=[].slice.call(arguments).join("");return function(t){var n=s(t.childNodes);t.innerHTML=e,function(e){var t=e.getElementsByTagName("content");if(t&&t.length){for(var n=[];t.length;){var r=t[0],o=r.parentNode,i=r.getAttribute("select"),a=document.createComment(" content "),d=document.createComment(" /content ");n.push({container:o,contentNode:r,defaultNodes:[].slice.call(r.childNodes),endNode:d,isDefault:!0,selector:i,startNode:a}),o.replaceChild(d,r),o.insertBefore(a,d),a.textContent+=JSON.stringify({defaultContent:r.innerHTML,selector:i})+" "}c(e,"content",n)}}(t),n.childNodes.length&&T.wrap(t).appendChild(n)}}T.wrap=function(e){return d(e,"content")||c(e,"content",function e(t){var n,r,o=t.childNodes,i=o.length,a=[];for(n=0;n<i;n++){var d=o[n];if(8===d.nodeType){var c=N(d);if(c)if("open"===c.type){if(r)throw new Error('Cannot have an opening content placeholder after another content placeholder at the same level in the DOM tree: "'+d.textContent+'" in "'+d.parentNode.innerHTML+'".');r={container:d.parentNode,contentNode:d,defaultNodes:c.data.defaultContent&&l(c.data.defaultContent).childNodes||[],isDefault:c.data.isDefault,selector:c.data.selector,startNode:d}}else if("close"===c.type){if(!r)throw new Error('Unmatched closing content placeholder: "'+d.textContent+'" in "'+d.parentNode.innerHTML+'".');r.endNode=d,a.push(r),r=void 0}}else a=a.concat(e(d))}return a}(e)),function(e,t){var n={};for(var r in e)r in t?Object.defineProperty(n,r,t[r]):Object.defineProperty(n,r,p(e,r));return n}(e,(n=d(t=e,"content"),r=n.length,{childNodes:{get:function(){for(var e=[],t=0;t<r;t++){var o=n[t];o.isDefault||(e=e.concat(f(o.startNode,o.endNode)))}return e}},firstChild:{get:function(){var e=this.childNodes;return e.length&&e[0]||null}},innerHTML:{get:function(){for(var e="",t=this.childNodes,n=t.length,r=0;r<n;r++){var o=t[r];e+=o.outerHTML||o.textContent}return e},set:function(e){for(var t=l(e),o=0;o<r;o++){for(var i=n[o],a=f(i.startNode,i.endNode),d=0;d<a.length;d++){var c=a[d];c.parentNode.removeChild(c)}for(var s=u(t,i.selector),p=0;p<s.length;p++)i.container.insertBefore(s[p],i.endNode);s.length?v(i):h(i)}}},lastChild:{get:function(){for(var e=r-1;e>-1;e--)if(!n[e].isDefault){var t=this.childNodes;return t[t.length-1]}return null}},outerHTML:{get:function(){var e=this.tagName.toLowerCase(),t="<"+e,n=this.attributes;if(n)for(var r=n.length,o=0;o<r;o++){var i=n[o];t+=" "+i.nodeName+'="'+i.nodeValue+'"'}return t+=">",t+=this.innerHTML,t+="</"+e+">"}},textContent:{get:function(){for(var e="",t=this.childNodes,n=this.childNodes.length,r=0;r<n;r++)e+=t[r].textContent;return e},set:function(e){var t;this.innerHTML="";for(var o=0;o<r;o++){var i=n[o];if(!i.selector){t=i;break}}t&&(e?(v(t),t.container.insertBefore(document.createTextNode(e),t.endNode)):h(t))}},appendChild:{value:function(e){if(e instanceof o){var t=e.childNodes;return[].slice.call(t).forEach(function(e){this.appendChild(e)}.bind(this)),this}for(var i=0;i<r;i++){var d=n[i],c=d.selector;if(!c||e instanceof window.HTMLElement&&a.call(e,c)){v(d),d.endNode.parentNode.insertBefore(e,d.endNode);break}}return this}},insertAdjacentHTML:{value:function(e,n){return"afterbegin"===e?this.insertBefore(l(n),this.childNodes[0]):"beforeend"===e?this.appendChild(l(n)):t.insertAdjacentHTML(e,n),this}},insertBefore:{value:function(e,t){if(!t)return this.appendChild(e);if(e instanceof o){var i=e.childNodes;if(i)for(var d=i.length,c=0;c<d;c++)this.insertBefore(i[c],t);return this}var l=!1;e:for(var s=0;s<r;s++)for(var u=n[s],h=f(u.startNode,u.endNode),v=h.length,p=0;p<v;p++){var N=h[p];if(N===t&&(l=!0),l){var T=u.selector;if(!T||a.call(e,T)){N.parentNode.insertBefore(e,N);break e}}}if(!l)throw new Error("DOMException 8: The node before which the new node is to be inserted is not a child of this node.");return e}},removeChild:{value:function(e){for(var t=!1,o=0;o<r;o++){var i=n[o];if(i.container===e.parentNode){i.container.removeChild(e),t=!0;break}i.startNode.nextSibling===i.endNode&&h(i)}if(!t)throw new Error("DOMException 8: The node in which you are trying to remove is not a child of this node.");return e}},replaceChild:{value:function(e,t){for(var o=0;o<r;o++){var i=n[o];if(i.container===t.parentNode){i.container.replaceChild(e,t);break}}return this}}}));var t,n,r},window.skateTemplateHtml=T,void 0===(r=function(){return T}.call(t,n,t,e))||(e.exports=r),e.exports=T}()}};