@modulor-js/html
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.MHTML={})}(this,function(e){"use strict";function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document.createTextNode(""),t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document.createTextNode("");return this.childNodes=[],this.firstChild=null,this.lastChild=null,this.startNode=e,this.stopNode=t,e&&t?e.parentNode!==t.parentNode?this:(this.update(),this):this}t.prototype.appendChild=function(e){this.stopNode.parentNode.insertBefore(e,this.stopNode),this.update()},t.prototype.removeChild=function(e){this.stopNode.parentNode.removeChild(e),this.update()},t.prototype.replaceChild=function(e,t){t.parentNode.replaceChild(e,t),this.update()},t.prototype.extractContents=function(){var e=document.createDocumentFragment();return e.appendChild(this.startNode),this.childNodes.reduce(function(e,t){return e.appendChild(t),e},e),e.appendChild(this.stopNode),e},t.prototype.update=function(){var e=this;this.childNodes=[];for(var t=this.startNode.nextSibling;t&&t!==this.stopNode;t=t.nextSibling)t.range&&(t.range.onUpdate=function(){return e.update()}),this.childNodes.push(t);this.firstChild=this.childNodes[0],this.lastChild=this.childNodes[this.childNodes.length-1],this.onUpdate&&this.onUpdate()},t.prototype.getByIndex=function(e){};var n=1,r=3,o=8,i=document.body.namespaceURI,u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function a(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function c(e,t){return e.nodeType===t.nodeType&&(e.tagName&&t.tagName&&e.tagName.toLowerCase()===t.tagName.toLowerCase())}function d(e){return void 0!==e}function s(e){return!!e&&("object"===(void 0===e?"undefined":u(e))||f(e))&&f(e.then)}function f(e){return"function"==typeof e}function l(e){return(void 0===e?"undefined":u(e))===u(!0)}function h(e){return e.replace(/[-[\]{}()*+!<=:?.\/\\^$|#\s,]/g,"\\$&")}var p=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var u,a=e[Symbol.iterator]();!(r=(u=a.next()).done)&&(n.push(u.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{!r&&a.return&&a.return()}finally{if(o)throw i}}return n}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();var m={},v=new Map,y=new Map,g=new DOMParser,C="{modulor_html_chunk_"+ +new Date+":",N="}",b="modulor_sanitize_node_"+ +new Date+":",x=new RegExp("<([ /])?("+["table","tr","td"].join("|")+")([ ][^]>)?","igm"),w=new RegExp(F(),"ig"),T=new RegExp(F(!0),"ig"),j=new RegExp("^"+F(!0)+"$");function A(e){return f(e)?"function":e instanceof Array?"array":e instanceof Node?"element":s(e)?"promise":d(e)?"text":"undefined"}function E(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return e.replace(T,function(e,n,r){var o=t[r];return d(o)?o:""})}function D(e,t,n){var r=t.name,o=t.value;if(s(o))o.then(function(t){return D(e,{name:r,value:t},n)});else if("style"!==r)if(f(r))r(e,o);else{if(!(n&&""===o)&&r in e)try{return void(e[r]=o)}catch(e){}e.setAttribute(r,o)}else!function(e){return e&&"object"===(void 0===e?"undefined":u(e))&&e.constructor===Object}(o)?e.setAttribute(r,o):Object.assign(e.style,o)}function R(e,t){if(d(e)&&""!==e){var n=A(e);return"promise"===n?e.then(function(e){return R(e,t)}):("array"===n?e:(""+e).split(" ")).forEach(function(e){return t(e)})}}function S(e){var t={nodeType:e.nodeType,namespaceURI:e.namespaceURI,textContent:e.textContent,attributes:[],childNodes:[]};e.tagName&&(t.tagName=e.tagName.toLowerCase().replace(b,"").toUpperCase());for(var n=e.attributes||[],i=function(r){var o=n[r],i=o.name,u=o.value,a=i.match(w),c=u.match(w),d=i.match(j),s=u.match(j);if("class"===i){var f=u.split(" ").reduce(function(e,t){return e[t.match(w)?0:1].push(t),e},[[],[]]),h=p(f,2),m=h[0],v=h[1];return t.attributes.push({name:i,value:v.join(" ")}),m.length&&t.attributes.push(function(e,t){return function(t,n){m.forEach(function(r){var o=r.match(j),i=o?t[o[2]]:E(r,t),u=o?n[o[2]]:E(r,n);u!==i&&(u&&R(u,function(t){return e.classList.remove(t)}),i&&R(i,function(t){return e.classList.add(t)}))})}}),"continue"}a||c?t.attributes.push(function(t){return function(n,r){var o=d?n[d[2]]:E(i,n),a=d?r[d[2]]:E(i,r),c=s?n[s[2]]:E(u,n),f=s?r[s[2]]:E(u,r);if((o!==a||c!==f)&&(o!==a&&t.removeAttribute(a),o))return D(t,{name:o,value:c},l(e[o])),function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}({},o,c)}}):t.attributes.push({name:i,value:u,isBoolean:l(e[i])})},u=0;u<n.length;u++)i(u);for(var a=e.childNodes||[],c=function(e){var n=a[e];return n.nodeType===r?(n.textContent.split(w).filter(function(e){return!!e}).forEach(function(e){var n=e.match(j);if(n){var o=n[2];t.childNodes.push(function(e){return function(t){return O(t[o],e)}})}else t.childNodes.push({nodeType:r,textContent:e})}),"continue"):n.nodeType===o?(n.textContent.match(w)?t.childNodes.push(function(e){var t=document.createComment(""),r=n.textContent;return e.appendChild(t),function(e){t.textContent=E(r,e)}}):t.childNodes.push({nodeType:o,textContent:n.textContent}),"continue"):void t.childNodes.push(S(n))},d=0;d<a.length;d++)c(d);return t}function k(e){var t,n=(t=e,Array.isArray(t)?t:Array.from(t)),r=n[0];return n.slice(1).reduce(function(e,t,n){var r=""+C+n+N;return e.concat(r).concat(t)},r)}function F(e){var t=(e?"(":"")+"\\d+"+(e?")":"");return"("+h(C)+t+h(N)+")"}function O(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document.createDocumentFragment(),n=v.get(t)||{},r=A(e),o=n.lastChunk,i=n.lastRenderedChunkType,u=n.update;if(o===e)return t;if("promise"===r)return I.promise(t,e),t;if(i!==r)a(t);else if(u){var c=u(e);return f(c)&&(n.update=c),n.lastChunk=e,t}return v.set(t,{update:I[r](t,e),lastRenderedChunkType:r,lastChunk:e}),t}var I={array:function e(t,n){var r=_({childNodes:[].concat(n).map(function(e,t){return function(e){return function(n){return O(n[t],e)}}})},t,{useDocFragment:!0}),o=p(r,2),i=o[0],u=o[1];return i(n),u(),function(r){if(r.length!==n.length)return e(t,r);i(r)}},undefined:a,text:function(e,t){var n=document.createTextNode(t);return e.appendChild(n),function(e){return n.textContent=e}},element:function(e,t){return e.appendChild(t),function(t){e.childNodes.length>1&&e.childNodes.slice(1).forEach(function(t){return e.removeChild(t)}),e.replaceChild(t,e.childNodes[0])}},promise:function(e,t){t.then(function(t){e.update(),O(t,e)})},function:function(e,t){var n=t(e);return function(t){n=t(e,n)}}};function U(e,t){for(var n=t.attributes,r=e.attributes,o=0;o<r.length;o++)e.removeAttribute(r[o].name);for(var i=[],u={},a=0;a<n.length;a++){var c=n[a];if(f(c))i.push(c(e));else{var d=c.name,s=c.value,l=c.isBoolean;D(e,{name:d,value:s},l),u[d]=s}}if("props"in e){if(i.length)return[function(t,n){var r=i.reduce(function(e,r){return Object.assign(e,r(t,n))},{});Object.keys(r).length&&(e.props=Object.assign(u,r))}];e.props=u}return i}function _(e,u){for(var a,d,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},l=[],h=s.useDocFragment?document.createDocumentFragment():u,p=e.childNodes,m=function(e){return e?function(t){return u.replaceChild(t,e)}:function(e){return h.appendChild(e)}},v=0,g=0;;v++){var C=p[v],N=u.childNodes[v+g];if(!C&&!N)break;if(C)if(N&&c(C,N))d=N,(r===(a=C).nodeType!==a.nodeType||a.textContent!==d.textContent)&&c(C,N)&&(l=l.concat(_(C,N)[0]).concat(U(N,C)));else{var b=m(N);if(f(C)){var x=y.get(N);if(!x){var w=(x=new t).startNode;b(x.extractContents()),y.set(w,x)}var T=C(x);T&&l.push(T),x.update(),g+=x.childNodes.length+1;continue}switch(C.nodeType){case r:b(document.createTextNode(C.textContent));break;case o:b(document.createComment(C.textContent));break;case n:var j=C.namespaceURI,A=C.tagName.toLowerCase(),E=j===i?document.createElement(A):document.createElementNS(j,A);l=l.concat(_(C,E)[0]).concat(U(E,C)),b(E)}}else u.removeChild(N),v--}var D=[];return[function e(t){return l.forEach(function(e){return e(t,D)}),D=t,e},function(){return s.useDocFragment?u.appendChild(h):void 0}]}e.NodesRange=t,e.emptyNode=a,e.render=O,e.morph=_,e.html=function(){for(var e=arguments.length,t=Array(e>1?e-1:0),n=1;n<e;n++)t[n-1]=arguments[n];var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(!r.length)return this;var o,i=function(e){for(var t=5381,n=e.length;n;)t=33*t^e.charCodeAt(--n);return t>>>0}(r.join(C+N)),u=m[i],a=void 0;if(d(u))a=u;else{var c=k(r);o=c.replace(x,"<$1"+b+"$2"),a=S(g.parseFromString(o,"text/html").body),m[i]=a}return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document.createDocumentFragment(),n=arguments[1];if(n&&n.templateId===i)return n(t);var r=_(a,e,{useDocFragment:!0}),o=p(r,2),u=o[0],c=o[1];return u(t),c(),u.templateId=i,u}},e.stopNode=function(){},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.MHTML={})}(this,function(e){"use strict";function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document.createTextNode(""),t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document.createTextNode("");return this.childNodes=[],this.firstChild=null,this.lastChild=null,this.startNode=e,this.stopNode=t,e&&t?e.parentNode!==t.parentNode?this:(this.update(),this):this}t.prototype.appendChild=function(e){this.stopNode.parentNode.insertBefore(e,this.stopNode),this.update()},t.prototype.removeChild=function(e){this.stopNode.parentNode.removeChild(e),this.update()},t.prototype.replaceChild=function(e,t){t.parentNode.replaceChild(e,t),this.update()},t.prototype.extractContents=function(){var e=document.createDocumentFragment();return e.appendChild(this.startNode),this.childNodes.reduce(function(e,t){return e.appendChild(t),e},e),e.appendChild(this.stopNode),e},t.prototype.update=function(){var e=this;this.childNodes=[];for(var t=this.startNode.nextSibling;t&&t!==this.stopNode;t=t.nextSibling)t.range&&(t.range.onUpdate=function(){return e.update()}),this.childNodes.push(t);this.firstChild=this.childNodes[0],this.lastChild=this.childNodes[this.childNodes.length-1],this.onUpdate&&this.onUpdate()},t.prototype.getByIndex=function(e){};var n=1,r=3,o=8,i=document.body.namespaceURI,u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function a(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function c(e,t){return e.nodeType===t.nodeType&&(e.tagName&&t.tagName&&e.tagName.toLowerCase()===t.tagName.toLowerCase())}function d(e){return void 0!==e}function s(e){return!!e&&("object"===(void 0===e?"undefined":u(e))||f(e))&&f(e.then)}function f(e){return"function"==typeof e}function l(e){return(void 0===e?"undefined":u(e))===u(!0)}function h(e){return e.replace(/[-[\]{}()*+!<=:?.\/\\^$|#\s,]/g,"\\$&")}var p=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var u,a=e[Symbol.iterator]();!(r=(u=a.next()).done)&&(n.push(u.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{!r&&a.return&&a.return()}finally{if(o)throw i}}return n}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();var m={},v=new Map,y=new Map,g=new DOMParser,C="{modulor_html_chunk_"+ +new Date+":",N="}",b="modulor_sanitize_node_"+ +new Date+":",x=new RegExp("<([ /])?("+["table","tr","td","style"].join("|")+")([ ][^]>)?","igm"),w=new RegExp(F(),"ig"),T=new RegExp(F(!0),"ig"),j=new RegExp("^"+F(!0)+"$");function A(e){return f(e)?"function":e instanceof Array?"array":e instanceof Node?"element":s(e)?"promise":d(e)?"text":"undefined"}function E(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return e.replace(T,function(e,n,r){var o=t[r];return d(o)?o:""})}function D(e,t,n){var r=t.name,o=t.value;if(s(o))o.then(function(t){return D(e,{name:r,value:t},n)});else if("style"!==r)if(f(r))r(e,o);else{if(!(n&&""===o)&&r in e)try{return void(e[r]=o)}catch(e){}e.setAttribute(r,o)}else!function(e){return e&&"object"===(void 0===e?"undefined":u(e))&&e.constructor===Object}(o)?e.setAttribute(r,o):Object.assign(e.style,o)}function R(e,t){if(d(e)&&""!==e){var n=A(e);return"promise"===n?e.then(function(e){return R(e,t)}):("array"===n?e:(""+e).split(" ")).forEach(function(e){return t(e)})}}function S(e){var t={nodeType:e.nodeType,namespaceURI:e.namespaceURI,textContent:e.textContent,attributes:[],childNodes:[]};e.tagName&&(t.tagName=e.tagName.toLowerCase().replace(b,"").toUpperCase());for(var n=e.attributes||[],i=function(r){var o=n[r],i=o.name,u=o.value,a=i.match(w),c=u.match(w),d=i.match(j),s=u.match(j);if("class"===i){var f=u.split(" ").reduce(function(e,t){return e[t.match(w)?0:1].push(t),e},[[],[]]),h=p(f,2),m=h[0],v=h[1];return t.attributes.push({name:i,value:v.join(" ")}),m.length&&t.attributes.push(function(e,t){return function(t,n){m.forEach(function(r){var o=r.match(j),i=o?t[o[2]]:E(r,t),u=o?n[o[2]]:E(r,n);u!==i&&(u&&R(u,function(t){return e.classList.remove(t)}),i&&R(i,function(t){return e.classList.add(t)}))})}}),"continue"}a||c?t.attributes.push(function(t){return function(n,r){var o=d?n[d[2]]:E(i,n),a=d?r[d[2]]:E(i,r),c=s?n[s[2]]:E(u,n),f=s?r[s[2]]:E(u,r);if((o!==a||c!==f)&&(o!==a&&t.removeAttribute(a),o))return D(t,{name:o,value:c},l(e[o])),function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}({},o,c)}}):t.attributes.push({name:i,value:u,isBoolean:l(e[i])})},u=0;u<n.length;u++)i(u);for(var a=e.childNodes||[],c=function(e){var n=a[e];return n.nodeType===r?(n.textContent.split(w).filter(function(e){return!!e}).forEach(function(e){var n=e.match(j);if(n){var o=n[2];t.childNodes.push(function(e){return function(t){return O(t[o],e)}})}else t.childNodes.push({nodeType:r,textContent:e})}),"continue"):n.nodeType===o?(n.textContent.match(w)?t.childNodes.push(function(e){var t=document.createComment(""),r=n.textContent;return e.appendChild(t),function(e){t.textContent=E(r,e)}}):t.childNodes.push({nodeType:o,textContent:n.textContent}),"continue"):void t.childNodes.push(S(n))},d=0;d<a.length;d++)c(d);return t}function k(e){var t,n=(t=e,Array.isArray(t)?t:Array.from(t)),r=n[0];return n.slice(1).reduce(function(e,t,n){var r=""+C+n+N;return e.concat(r).concat(t)},r)}function F(e){var t=(e?"(":"")+"\\d+"+(e?")":"");return"("+h(C)+t+h(N)+")"}function O(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document.createDocumentFragment(),n=v.get(t)||{},r=A(e),o=n.lastChunk,i=n.lastRenderedChunkType,u=n.update;if(o===e)return t;if("promise"===r)return I.promise(t,e),t;if(i!==r)a(t);else if(u){var c=u(e);return f(c)&&(n.update=c),n.lastChunk=e,t}return v.set(t,{update:I[r](t,e),lastRenderedChunkType:r,lastChunk:e}),t}var I={array:function e(t,n){var r=_({childNodes:[].concat(n).map(function(e,t){return function(e){return function(n){return O(n[t],e)}}})},t,{useDocFragment:!0}),o=p(r,2),i=o[0],u=o[1];return i(n),u(),function(r){if(r.length!==n.length)return e(t,r);i(r)}},undefined:a,text:function(e,t){var n=document.createTextNode(t);return e.appendChild(n),function(e){return n.textContent=e}},element:function(e,t){return e.appendChild(t),function(t){e.childNodes.length>1&&e.childNodes.slice(1).forEach(function(t){return e.removeChild(t)}),e.replaceChild(t,e.childNodes[0])}},promise:function(e,t){t.then(function(t){e.update(),O(t,e)})},function:function(e,t){var n=t(e);return function(t){n=t(e,n)}}};function U(e,t){for(var n=t.attributes,r=e.attributes,o=0;o<r.length;o++)e.removeAttribute(r[o].name);for(var i=[],u={},a=0;a<n.length;a++){var c=n[a];if(f(c))i.push(c(e));else{var d=c.name,s=c.value,l=c.isBoolean;D(e,{name:d,value:s},l),u[d]=s}}if("props"in e){if(i.length)return[function(t,n){var r=i.reduce(function(e,r){return Object.assign(e,r(t,n))},{});Object.keys(r).length&&(e.props=Object.assign(u,r))}];e.props=u}return i}function _(e,u){for(var a,d,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},l=[],h=s.useDocFragment?document.createDocumentFragment():u,p=e.childNodes,m=function(e){return e?function(t){return u.replaceChild(t,e)}:function(e){return h.appendChild(e)}},v=0,g=0;;v++){var C=p[v],N=u.childNodes[v+g];if(!C&&!N)break;if(C)if(N&&c(C,N))d=N,(r===(a=C).nodeType!==a.nodeType||a.textContent!==d.textContent)&&c(C,N)&&(l=l.concat(_(C,N)[0]).concat(U(N,C)));else{var b=m(N);if(f(C)){var x=y.get(N);if(!x){var w=(x=new t).startNode;b(x.extractContents()),y.set(w,x)}var T=C(x);T&&l.push(T),x.update(),g+=x.childNodes.length+1;continue}switch(C.nodeType){case r:b(document.createTextNode(C.textContent));break;case o:b(document.createComment(C.textContent));break;case n:var j=C.namespaceURI,A=C.tagName.toLowerCase(),E=j===i?document.createElement(A):document.createElementNS(j,A);l=l.concat(_(C,E)[0]).concat(U(E,C)),b(E)}}else u.removeChild(N),v--}var D=[];return[function e(t){return l.forEach(function(e){return e(t,D)}),D=t,e},function(){return s.useDocFragment?u.appendChild(h):void 0}]}e.NodesRange=t,e.emptyNode=a,e.render=O,e.morph=_,e.html=function(){for(var e=arguments.length,t=Array(e>1?e-1:0),n=1;n<e;n++)t[n-1]=arguments[n];var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(!r.length)return this;var o,i=function(e){for(var t=5381,n=e.length;n;)t=33*t^e.charCodeAt(--n);return t>>>0}(r.join(C+N)),u=m[i],a=void 0;if(d(u))a=u;else{var c=k(r);o=c.replace(x,"<$1"+b+"$2"),a=S(g.parseFromString(o,"text/html").body),m[i]=a}return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document.createDocumentFragment(),n=arguments[1];if(n&&n.templateId===i)return n(t);var r=_(a,e,{useDocFragment:!0}),o=p(r,2),u=o[0],c=o[1];return u(t),c(),u.templateId=i,u}},e.stopNode=function(){},Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "@modulor-js/html", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Template engine based on tagged template literals", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,4 +0,6 @@ | ||
# modulor-html [![GitHub license](https://img.shields.io/github/license/modulor-js/modulor-html.svg)](./LICENSE) [![Codecov](https://img.shields.io/codecov/c/github/modulor-js/modulor-html.svg)](https://codecov.io/gh/modulor-js/modulor-html) [![npm bundle size (minified + gzip)](https://img.shields.io/bundlephobia/minzip/@modulor-js/html.svg)](https://bundlephobia.com/result?p=@modulor-js/html) [![Build Status](https://travis-ci.org/modulor-js/modulor-html.svg?branch=master)](https://travis-ci.org/modulor-js/modulor-html) [![David (path)](https://img.shields.io/david/modulor-js/modulor-html.svg)](https://david-dm.org/modulor-js/modulor-html) | ||
# modulor-html [![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Missing%20template%20engine%20for%20Web%20Components&url=https://github.com/modulor-js/modulor-html&hashtags=webcomponents,template-engine,js) | ||
[![GitHub license](https://img.shields.io/github/license/modulor-js/modulor-html.svg)](./LICENSE) [![Codecov](https://img.shields.io/codecov/c/github/modulor-js/modulor-html.svg)](https://codecov.io/gh/modulor-js/modulor-html) [![npm bundle size (minified + gzip)](https://img.shields.io/bundlephobia/minzip/@modulor-js/html.svg)](https://bundlephobia.com/result?p=@modulor-js/html) [![Build Status](https://travis-ci.org/modulor-js/modulor-html.svg?branch=master)](https://travis-ci.org/modulor-js/modulor-html) [![David (path)](https://img.shields.io/david/modulor-js/modulor-html.svg)](https://david-dm.org/modulor-js/modulor-html) | ||
@@ -5,0 +7,0 @@ <img align="center" width="95" height="95" |
@@ -22,3 +22,3 @@ import { NodesRange } from './range'; | ||
let sanitizeNodePrefix = `modulor_sanitize_node_${+(new Date())}:`; | ||
const sanitizeTags = ['table', 'tr', 'td']; | ||
const sanitizeTags = ['table', 'tr', 'td', 'style']; | ||
const sanitizeTagsRegex = new RegExp(`<([ /])?(${sanitizeTags.join('|')})([ ][^]>)?`, 'igm'); | ||
@@ -25,0 +25,0 @@ |
@@ -131,2 +131,28 @@ import 'web-components-polyfill'; | ||
describe('<style> tag', () => { | ||
const template = (color) => html` | ||
<style> | ||
.test-input { color: ${color}; } | ||
</style> | ||
<input class="test-input" /> | ||
`; | ||
const fixture = (color) => `<style> | ||
.test-input { color: ${color}; } | ||
</style> | ||
<input class="test-input"> | ||
`; | ||
const $container = document.createElement('div'); | ||
it('renders correctly', () => { | ||
const value1 = 'red' | ||
const value2 = 'green' | ||
render(template(value1), $container); | ||
expect($container.innerHTML).toBe(fixture(value1)); | ||
render(template(value2), $container); | ||
expect($container.innerHTML).toBe(fixture(value2)); | ||
}); | ||
}); | ||
describe('transitions', () => { | ||
@@ -133,0 +159,0 @@ |
@@ -108,2 +108,14 @@ import { html, prepareLiterals, replaceTokens, sanitize, setPrefix, setPostfix, setSanitizeNodePrefix, updateChunkRegexes } from '../../src/html'; | ||
}, | ||
{ | ||
input: ` | ||
<style> | ||
.foo > .bar { } | ||
</style> | ||
`, | ||
expectation: ` | ||
<sanitize:style> | ||
.foo > .bar { } | ||
</sanitize:style> | ||
` | ||
}, | ||
] | ||
@@ -110,0 +122,0 @@ testSets.forEach((testSet, index) => { |
1169752
3620
97