From f22f6b2bc8458aabb788777d79a5aca6045f3586 Mon Sep 17 00:00:00 2001 From: grainsoft Date: Wed, 3 Dec 2025 01:32:26 +0200 Subject: [PATCH] updates --- src/utils/AppendOptions.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/utils/AppendOptions.js b/src/utils/AppendOptions.js index c5a54de..2871269 100644 --- a/src/utils/AppendOptions.js +++ b/src/utils/AppendOptions.js @@ -2,14 +2,16 @@ import { Ut } from "./Ut"; export class AppendOptions { - constructor(target, data, opts) { + constructor(target, data, opts) { - opts = opts || {}; + opts = opts || {}; - if (opts.clear) { - this.replaceChildren(); - } + if (opts.clear) { + 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)) ); + } } \ No newline at end of file