This commit is contained in:
2025-12-03 01:32:26 +02:00
parent 2b3b56179a
commit f22f6b2bc8
+9 -7
View File
@@ -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)) );
}
} }