Add getter and setter for name

This commit is contained in:
Talia 2025-01-23 19:21:50 +01:00
parent 8499177fde
commit 078abf35ac
Signed by: darkwiiplayer
GPG key ID: 7808674088232B3E
2 changed files with 18 additions and 3 deletions

View file

@ -3,6 +3,6 @@
"browser": "src/BetterSelect.js", "browser": "src/BetterSelect.js",
"type": "module", "type": "module",
"license": "MIT", "license": "MIT",
"version": "1.4.1", "version": "1.4.2",
"url": "https://darkwiiplayer.github.io/BetterSelect/" "url": "https://darkwiiplayer.github.io/BetterSelect/"
} }

View file

@ -1,5 +1,11 @@
/**
* @param {function} fn
*/
const template = fn => { const template = fn => {
/**
* @param {TemplateStringsArray|String} arr
* @param {string[]} params
*/
return (arr, ...params) => { return (arr, ...params) => {
if (arr instanceof Array) { if (arr instanceof Array) {
const buffer = [] const buffer = []
@ -410,6 +416,16 @@ export class BetterSelect extends HTMLElement {
this.input.placeholder = text this.input.placeholder = text
} }
/**
* @return {String}
*/
get name() { return this.getAttribute("name") }
/**
* @param {String} name
*/
set name(name) { this.setAttribute("name", String(name)) }
clear() { clear() {
this.setValue(undefined, "") this.setValue(undefined, "")
} }
@ -424,4 +440,3 @@ export class BetterSelect extends HTMLElement {
if (methodName in this) this[methodName](after, before) if (methodName in this) this[methodName](after, before)
} }
} }