updates
This commit is contained in:
@@ -2,14 +2,16 @@ import { Ut } from "./Ut";
|
|||||||
|
|
||||||
export class AppendOptions {
|
export class AppendOptions {
|
||||||
|
|
||||||
constructor(target, data, opts) {
|
constructor(target, data, opts) {
|
||||||
|
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
|
|
||||||
if (opts.clear) {
|
if (opts.clear) {
|
||||||
this.replaceChildren();
|
this.replaceChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ut.each(Ut.isStr(data) ? JSON.parse(data) : data, (val, id) => target.append(new Option(val, id)) );
|
Ut.each(Ut.isStr(data)
|
||||||
}
|
? data.replace(/"((?:\\.|[^"\\])*)"\s*:\s*"((?:\\.|[^"\\])*)"/g, (_, rawKey, rawVal) => target.append(new Option(JSON.parse(`"${rawVal}"`), JSON.parse(`"${rawKey}"`) )) )
|
||||||
|
: data, (val, id) => target.append(new Option(val, id)) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user