@ne1410s/cust-elems
Advanced tools
Comparing version 0.1.5 to 0.2.0
@@ -1,5 +0,2 @@ | ||
export declare abstract class CustomElementBase extends HTMLElement { | ||
protected root: ShadowRoot; | ||
constructor(css: string, html: string, mode?: ShadowRootMode); | ||
protected decode(b64: string): string; | ||
} | ||
export { CustomElementBase } from './custom-element-base'; | ||
export * from './custom-element-static'; |
@@ -9,13 +9,26 @@ 'use strict'; | ||
this.root = this.attachShadow({ mode }); | ||
this.root.innerHTML = this.decode(html); | ||
this.root.innerHTML = html; | ||
const style = document.createElement('style'); | ||
style.textContent = this.decode(css); | ||
style.textContent = css; | ||
this.root.appendChild(style); | ||
} | ||
decode(b64) { | ||
const bIndex = (b64 + '').indexOf('base64,'); | ||
return bIndex === -1 ? b64 : window.atob(b64.substring(bIndex + 7)); | ||
} | ||
} | ||
function decode(b64) { | ||
const bIndex = (b64 + '').indexOf('base64,'); | ||
return bIndex === -1 ? b64 : window.atob(b64.substring(bIndex + 7)); | ||
} | ||
function reduceCss(cssIn) { | ||
return cssIn | ||
.replace(/\s+/g, ' ') | ||
.replace(/([,{}:;])\s/g, '$1') | ||
.replace(/\s([{])/g, '$1'); | ||
} | ||
function reduceHtml(htmlIn) { | ||
return htmlIn.replace(/\s+/g, ' ').replace(/>\s</g, '><'); | ||
} | ||
exports.CustomElementBase = CustomElementBase; | ||
exports.decode = decode; | ||
exports.reduceCss = reduceCss; | ||
exports.reduceHtml = reduceHtml; |
@@ -5,13 +5,23 @@ class CustomElementBase extends HTMLElement { | ||
this.root = this.attachShadow({ mode }); | ||
this.root.innerHTML = this.decode(html); | ||
this.root.innerHTML = html; | ||
const style = document.createElement('style'); | ||
style.textContent = this.decode(css); | ||
style.textContent = css; | ||
this.root.appendChild(style); | ||
} | ||
decode(b64) { | ||
const bIndex = (b64 + '').indexOf('base64,'); | ||
return bIndex === -1 ? b64 : window.atob(b64.substring(bIndex + 7)); | ||
} | ||
} | ||
export { CustomElementBase }; | ||
function decode(b64) { | ||
const bIndex = (b64 + '').indexOf('base64,'); | ||
return bIndex === -1 ? b64 : window.atob(b64.substring(bIndex + 7)); | ||
} | ||
function reduceCss(cssIn) { | ||
return cssIn | ||
.replace(/\s+/g, ' ') | ||
.replace(/([,{}:;])\s/g, '$1') | ||
.replace(/\s([{])/g, '$1'); | ||
} | ||
function reduceHtml(htmlIn) { | ||
return htmlIn.replace(/\s+/g, ' ').replace(/>\s</g, '><'); | ||
} | ||
export { CustomElementBase, decode, reduceCss, reduceHtml }; |
@@ -11,14 +11,27 @@ (function (global, factory) { | ||
this.root = this.attachShadow({ mode }); | ||
this.root.innerHTML = this.decode(html); | ||
this.root.innerHTML = html; | ||
const style = document.createElement('style'); | ||
style.textContent = this.decode(css); | ||
style.textContent = css; | ||
this.root.appendChild(style); | ||
} | ||
decode(b64) { | ||
const bIndex = (b64 + '').indexOf('base64,'); | ||
return bIndex === -1 ? b64 : window.atob(b64.substring(bIndex + 7)); | ||
} | ||
} | ||
function decode(b64) { | ||
const bIndex = (b64 + '').indexOf('base64,'); | ||
return bIndex === -1 ? b64 : window.atob(b64.substring(bIndex + 7)); | ||
} | ||
function reduceCss(cssIn) { | ||
return cssIn | ||
.replace(/\s+/g, ' ') | ||
.replace(/([,{}:;])\s/g, '$1') | ||
.replace(/\s([{])/g, '$1'); | ||
} | ||
function reduceHtml(htmlIn) { | ||
return htmlIn.replace(/\s+/g, ' ').replace(/>\s</g, '><'); | ||
} | ||
exports.CustomElementBase = CustomElementBase; | ||
exports.decode = decode; | ||
exports.reduceCss = reduceCss; | ||
exports.reduceHtml = reduceHtml; | ||
@@ -25,0 +38,0 @@ Object.defineProperty(exports, '__esModule', { value: true }); |
{ | ||
"name": "@ne1410s/cust-elems", | ||
"version": "0.1.5", | ||
"version": "0.2.0", | ||
"description": "ES Custom Elements base functionality", | ||
@@ -43,7 +43,7 @@ "main": "dist/ne14_cust_elems.cjs.min.js", | ||
"rimraf": "^3.0.1", | ||
"rollup": "^2.31.0", | ||
"rollup": "^2.33.2", | ||
"rollup-plugin-copy": "^3.3.0", | ||
"rollup-plugin-typescript2": "^0.27.3", | ||
"typescript": "^4.0.3" | ||
"rollup-plugin-typescript2": "^0.29.0", | ||
"typescript": "^4.0.5" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6553
9
96