10000 Fix ESLint warnings (#294) · sarvjeetdev/pyscript@6f18a66 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6f18a66

Browse files
authored
Fix ESLint warnings (pyscript#294)
* Use builtin methods * Fix formatting
1 parent 5332aad commit 6f18a66

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

pyscriptjs/src/components/pybutton.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,27 @@ export class PyButton extends BaseEvalElement {
1212
mount_name: string;
1313
constructor() {
1414
super();
15-
this.defaultClass = ['p-2', 'text-white', 'bg-blue-600', 'border', 'border-blue-600','rounded']
15+
16+
this.defaultClass = ['p-2', 'text-white', 'bg-blue-600', 'border', 'border-blue-600', 'rounded'];
17+
1618
if (this.hasAttribute('label')) {
1719
this.label = this.getAttribute('label');
1820
}
1921

2022
// Styling does the same thing as class in normal HTML. Using the name "class" makes the style to malfunction
2123
if (this.hasAttribute('styling')) {
22-
let klass = this.getAttribute('styling');
23-
if (klass.trim() == ''){
24-
this.class = this.defaultClass
25-
}else{
26-
klass = klass.trim()
27-
const newClassArray = klass.split(' ');
24+
const klass = this.getAttribute('styling').trim();
25+
if (klass === '') {
26+
this.class = this.defaultClass;
27+
} else {
2828
// trim each element to remove unnecessary spaces which makes the button style to malfunction
29-
this.class = (() => {const concatenatedString = []; for (let i = 0; i < newClassArray.length; i++) {if (newClassArray[i].trim() !== '')(concatenatedString.push(newClassArray[i].trim()));} return concatenatedString;})();
29+
this.class = klass
30+
.split(' ')
31+
.map(x => x.trim())
32+
.filter(x => x !== '');
3033
}
31-
}
32-
else {
33-
this.class = this.defaultClass
34+
} else {
35+
this.class = this.defaultClass;
3436
}
3537
}
3638

0 commit comments

Comments
 (0)
0