ts strict - getAttribute (#863)

* ts strict getAttribute

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* mark xfail

* fix to string

* Remove

* use getAttribute for theme

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Ted Patrick
2022-10-21 07:47:44 -05:00
committed by GitHub
parent 58b4df6b3d
commit c352b502c4
11 changed files with 131 additions and 80 deletions

View File

@@ -1,4 +1,4 @@
import { addClasses } from '../utils';
import { getAttribute, addClasses } from '../utils';
import { getLogger } from '../logger';
const logger = getLogger('py-box');
@@ -7,7 +7,7 @@ export class PyBox extends HTMLElement {
shadow: ShadowRoot;
wrapper: HTMLElement;
theme: string;
widths: Array<string>;
widths: string[];
constructor() {
super();
@@ -47,10 +47,14 @@ export class PyBox extends HTMLElement {
// now we need to set widths
this.widths = [];
if (this.hasAttribute('widths')) {
for (const w of this.getAttribute('widths').split(';')) {
if (w.includes('/')) this.widths.push(w.split('/')[0])
else this.widths.push(w)
const widthsAttr = getAttribute( this, "widths" );
if (widthsAttr) {
for (const w of widthsAttr.split(';')) {
if (w.includes('/')){
this.widths.push(w.split('/')[0])
}else{
this.widths.push(w)
}
}
} else {
this.widths = Array<string>(mainDiv.children.length).fill('1 1 0');