@aplazame/browser
Advanced tools
Comparing version 0.1.13 to 0.1.14
@@ -15,3 +15,4 @@ import { EventEmitter, DetailsEvent } from './EventEmitter.js'; | ||
currentStyles: { | ||
[key: string]: string; | ||
[key: string]: unknown; | ||
important?: Record<string, string>; | ||
}; | ||
@@ -41,8 +42,16 @@ currentAttributes: { | ||
}): this; | ||
setStyles(styles: string | { | ||
[key: string]: string; | ||
setStyles(styles?: { | ||
[key: string]: unknown; | ||
important?: Record<string, string>; | ||
}): this; | ||
applyStyles(styles?: { | ||
[key: string]: unknown; | ||
important?: Record<string, string> | undefined; | ||
}): this; | ||
setAttributes(attributes: { | ||
[key: string]: string; | ||
}): this; | ||
applyAttributes(attributes?: { | ||
[key: string]: string; | ||
}): this; | ||
resetStyles(): this; | ||
@@ -49,0 +58,0 @@ resetAttributes(): void; |
@@ -94,5 +94,4 @@ "use strict"; | ||
this.iframe.src = this.url.toString(); | ||
Object.assign(this.iframe.style, this.currentStyles); | ||
for (const key in this.currentAttributes) | ||
this.iframe.setAttribute(key, this.currentAttributes[key]); | ||
this.applyStyles(); | ||
this.applyAttributes(); | ||
el.appendChild(this.iframe); | ||
@@ -109,3 +108,3 @@ // listening messages | ||
} | ||
setStyles(styles) { | ||
setStyles(styles = {}) { | ||
var _a; | ||
@@ -116,9 +115,19 @@ const newSytles = typeof styles === 'string' | ||
this.currentStyles = Object.assign(Object.assign({}, this.currentStyles), newSytles); | ||
this.applyStyles(); | ||
return this; | ||
} | ||
applyStyles(styles = this.currentStyles) { | ||
const iframe = this.iframe; | ||
if (iframe) { | ||
Object.keys(newSytles).forEach(key => { | ||
if (newSytles[key] === null) | ||
Object.keys(styles).forEach(key => { | ||
if (key === 'important') { | ||
for (const key in styles.important) { | ||
iframe.style.setProperty(key, String(styles[key]), 'important'); | ||
} | ||
return; | ||
} | ||
if (styles[key] === null) | ||
iframe.style.removeProperty(key); | ||
else | ||
iframe.style.setProperty(key, newSytles[key]); | ||
iframe.style.setProperty(key, String(styles[key])); | ||
}); | ||
@@ -130,2 +139,6 @@ } | ||
this.currentAttributes = Object.assign(Object.assign({}, this.currentAttributes), attributes); | ||
this.applyAttributes(); | ||
return this; | ||
} | ||
applyAttributes(attributes = this.currentAttributes) { | ||
const iframe = this.iframe; | ||
@@ -132,0 +145,0 @@ if (iframe) { |
{ | ||
"name": "@aplazame/browser", | ||
"version": "0.1.13", | ||
"version": "0.1.14", | ||
"description": "Aplazame SDK for browser", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
23078
519