Fix ESLint warnings (#294)

* Use builtin methods

* Fix formatting
This commit is contained in:
woxtu
2022-05-10 05:16:25 +09:00
committed by GitHub
parent 5332aad8d6
commit 6f18a66d53

View File

@@ -12,25 +12,27 @@ export class PyButton extends BaseEvalElement {
mount_name: string;
constructor() {
super();
this.defaultClass = ['p-2', 'text-white', 'bg-blue-600', 'border', 'border-blue-600','rounded']
this.defaultClass = ['p-2', 'text-white', 'bg-blue-600', 'border', 'border-blue-600', 'rounded'];
if (this.hasAttribute('label')) {
this.label = this.getAttribute('label');
}
// Styling does the same thing as class in normal HTML. Using the name "class" makes the style to malfunction
if (this.hasAttribute('styling')) {
let klass = this.getAttribute('styling');
if (klass.trim() == ''){
this.class = this.defaultClass
}else{
klass = klass.trim()
const newClassArray = klass.split(' ');
const klass = this.getAttribute('styling').trim();
if (klass === '') {
this.class = this.defaultClass;
} else {
// trim each element to remove unnecessary spaces which makes the button style to malfunction
this.class = (() => {const concatenatedString = []; for (let i = 0; i < newClassArray.length; i++) {if (newClassArray[i].trim() !== '')(concatenatedString.push(newClassArray[i].trim()));} return concatenatedString;})();
this.class = klass
.split(' ')
.map(x => x.trim())
.filter(x => x !== '');
}
}
else {
this.class = this.defaultClass
} else {
this.class = this.defaultClass;
}
}