@aplazame/browser
Advanced tools
Comparing version 0.1.11 to 0.1.12
@@ -17,2 +17,5 @@ import { EventEmitter, DetailsEvent } from './EventEmitter.js'; | ||
}; | ||
currentAttributes: { | ||
[key: string]: string; | ||
}; | ||
constructor({ url, searchParams, requestTimeout, allowFilter, sendData }?: { | ||
@@ -41,4 +44,8 @@ url?: string | null; | ||
}): this; | ||
setAttributes(attributes: { | ||
[key: string]: string; | ||
}): this; | ||
resetStyles(): this; | ||
resetAttributes(): void; | ||
unmount(): void; | ||
} |
@@ -44,2 +44,3 @@ "use strict"; | ||
this.currentStyles = {}; | ||
this.currentAttributes = {}; | ||
if (!url) | ||
@@ -95,2 +96,4 @@ throw new Error('url is required'); | ||
Object.assign(this.iframe.style, this.currentStyles); | ||
for (const key in this.currentAttributes) | ||
this.iframe.setAttribute(key, this.currentAttributes[key]); | ||
el.appendChild(this.iframe); | ||
@@ -124,2 +127,15 @@ // listening messages | ||
} | ||
setAttributes(attributes) { | ||
this.currentAttributes = Object.assign(Object.assign({}, this.currentAttributes), attributes); | ||
const iframe = this.iframe; | ||
if (iframe) { | ||
for (const key in attributes) { | ||
if (attributes[key] === null) | ||
iframe.removeAttribute(key); | ||
else | ||
iframe.setAttribute(key, attributes[key]); | ||
} | ||
} | ||
return this; | ||
} | ||
resetStyles() { | ||
@@ -134,2 +150,10 @@ var _a; | ||
} | ||
resetAttributes() { | ||
const iframe = this.iframe; | ||
if (iframe) { | ||
Object.keys(this.currentAttributes).forEach(key => iframe.removeAttribute(key)); | ||
} | ||
this.currentAttributes = {}; | ||
return; | ||
} | ||
unmount() { | ||
@@ -136,0 +160,0 @@ var _a; |
{ | ||
"name": "@aplazame/browser", | ||
"version": "0.1.11", | ||
"version": "0.1.12", | ||
"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
22429
497