valyrian.js 7.2.6 → 7.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/node/index.js
CHANGED
|
@@ -223,7 +223,7 @@ var Element = class extends Node {
|
|
|
223
223
|
this.attributes = [];
|
|
224
224
|
this.childNodes = [];
|
|
225
225
|
}
|
|
226
|
-
|
|
226
|
+
_style = new Proxy(
|
|
227
227
|
{},
|
|
228
228
|
{
|
|
229
229
|
get: (state, prop) => state[prop],
|
|
@@ -239,6 +239,20 @@ var Element = class extends Node {
|
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
241
|
);
|
|
242
|
+
get style() {
|
|
243
|
+
return this._style;
|
|
244
|
+
}
|
|
245
|
+
set style(value) {
|
|
246
|
+
if (typeof value === "string") {
|
|
247
|
+
const regex = /([^:\s]+):\s*((url\([^)]+\))|[^;]+(?=(;|$)))/g;
|
|
248
|
+
let match;
|
|
249
|
+
while ((match = regex.exec(value)) !== null) {
|
|
250
|
+
this._style[match[1]] = match[2].trim();
|
|
251
|
+
}
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
throw new Error("Cannot set style");
|
|
255
|
+
}
|
|
242
256
|
classList = {
|
|
243
257
|
toggle: (item, force) => {
|
|
244
258
|
if (item) {
|
|
@@ -523,20 +537,20 @@ function getObjectIndexTree(html) {
|
|
|
523
537
|
let attributesWithValues = string.match(/\S+="[^"]+"/g);
|
|
524
538
|
if (attributesWithValues) {
|
|
525
539
|
for (let attribute of attributesWithValues) {
|
|
526
|
-
const [name, value] = attribute.trim().split("=");
|
|
540
|
+
const [name, ...value] = attribute.trim().split("=");
|
|
527
541
|
string = string.replace(attribute, "");
|
|
528
542
|
if (value) {
|
|
529
|
-
element.attributes[name] = value.replace(/(^"|"$)/g, "");
|
|
543
|
+
element.attributes[name] = value.join("=").replace(/(^"|"$)/g, "");
|
|
530
544
|
}
|
|
531
545
|
}
|
|
532
546
|
}
|
|
533
547
|
let attributesWithBooleanValues = string.match(/\s\S+=[^"]+/g);
|
|
534
548
|
if (attributesWithBooleanValues) {
|
|
535
549
|
for (let attribute of attributesWithBooleanValues) {
|
|
536
|
-
const [name, value] = attribute.trim().split("=");
|
|
550
|
+
const [name, ...value] = attribute.trim().split("=");
|
|
537
551
|
string = string.replace(attribute, "");
|
|
538
552
|
if (value) {
|
|
539
|
-
element.attributes[name] = value;
|
|
553
|
+
element.attributes[name] = value.join("=").replace(/(^"|"$)/g, "");
|
|
540
554
|
}
|
|
541
555
|
}
|
|
542
556
|
}
|
package/dist/node/index.mjs
CHANGED
|
@@ -185,7 +185,7 @@ var Element = class extends Node {
|
|
|
185
185
|
this.attributes = [];
|
|
186
186
|
this.childNodes = [];
|
|
187
187
|
}
|
|
188
|
-
|
|
188
|
+
_style = new Proxy(
|
|
189
189
|
{},
|
|
190
190
|
{
|
|
191
191
|
get: (state, prop) => state[prop],
|
|
@@ -201,6 +201,20 @@ var Element = class extends Node {
|
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
);
|
|
204
|
+
get style() {
|
|
205
|
+
return this._style;
|
|
206
|
+
}
|
|
207
|
+
set style(value) {
|
|
208
|
+
if (typeof value === "string") {
|
|
209
|
+
const regex = /([^:\s]+):\s*((url\([^)]+\))|[^;]+(?=(;|$)))/g;
|
|
210
|
+
let match;
|
|
211
|
+
while ((match = regex.exec(value)) !== null) {
|
|
212
|
+
this._style[match[1]] = match[2].trim();
|
|
213
|
+
}
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
throw new Error("Cannot set style");
|
|
217
|
+
}
|
|
204
218
|
classList = {
|
|
205
219
|
toggle: (item, force) => {
|
|
206
220
|
if (item) {
|
|
@@ -485,20 +499,20 @@ function getObjectIndexTree(html) {
|
|
|
485
499
|
let attributesWithValues = string.match(/\S+="[^"]+"/g);
|
|
486
500
|
if (attributesWithValues) {
|
|
487
501
|
for (let attribute of attributesWithValues) {
|
|
488
|
-
const [name, value] = attribute.trim().split("=");
|
|
502
|
+
const [name, ...value] = attribute.trim().split("=");
|
|
489
503
|
string = string.replace(attribute, "");
|
|
490
504
|
if (value) {
|
|
491
|
-
element.attributes[name] = value.replace(/(^"|"$)/g, "");
|
|
505
|
+
element.attributes[name] = value.join("=").replace(/(^"|"$)/g, "");
|
|
492
506
|
}
|
|
493
507
|
}
|
|
494
508
|
}
|
|
495
509
|
let attributesWithBooleanValues = string.match(/\s\S+=[^"]+/g);
|
|
496
510
|
if (attributesWithBooleanValues) {
|
|
497
511
|
for (let attribute of attributesWithBooleanValues) {
|
|
498
|
-
const [name, value] = attribute.trim().split("=");
|
|
512
|
+
const [name, ...value] = attribute.trim().split("=");
|
|
499
513
|
string = string.replace(attribute, "");
|
|
500
514
|
if (value) {
|
|
501
|
-
element.attributes[name] = value;
|
|
515
|
+
element.attributes[name] = value.join("=").replace(/(^"|"$)/g, "");
|
|
502
516
|
}
|
|
503
517
|
}
|
|
504
518
|
}
|
|
@@ -38,7 +38,9 @@ export declare class Text extends Node {
|
|
|
38
38
|
}
|
|
39
39
|
export declare class Element extends Node {
|
|
40
40
|
constructor();
|
|
41
|
-
|
|
41
|
+
_style: Record<string, any>;
|
|
42
|
+
get style(): string;
|
|
43
|
+
set style(value: string);
|
|
42
44
|
classList: {
|
|
43
45
|
toggle: (item: any, force: any) => void;
|
|
44
46
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree-adapter.d.ts","sourceRoot":"","sources":["../../../lib/node/utils/tree-adapter.ts"],"names":[],"mappings":"AAEA,UAAU,UAAW,SAAQ,KAAK,CAAC,IAAI,GAAG,OAAO,GAAG,IAAI,GAAG,gBAAgB,CAAC;CAAG;AAE/E,qBAAa,IAAK,YAAW,IAAI;IAE/B,UAAU,EAAE,UAAU,CAAM;IAC5B,OAAO,EAAE,MAAM,CAAM;IAErB,QAAQ,EAAG,MAAM,CAAC;IAClB,IAAI,QAAQ,IAAI,MAAM,CAErB;IACD,IAAI,QAAQ,CAA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I,SAAS,CAAC,IAAI,QAAA,EAEjB;IAED,IAAI,SAAS,WAEZ;IAED,IAAI,SAAS,WAOZ;IAED,IAAI,SAAS,CAAC,IAAI,QAAA,EAUjB;IAED,IAAI,SAAS,IAAI,MAAM,CAEtB;CACF;AAED,qBAAa,gBAAiB,SAAQ,OAAO;;CAM5C;AAED,qBAAa,QAAS,SAAQ,OAAO;;IAOnC,sBAAsB,IAAI,gBAAgB;IAI1C,aAAa,CAAC,IAAI,EAAE,MAAM;IAM1B,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAMxC,cAAc,CAAC,IAAI,EAAE,GAAG;CAGzB;AAoBD,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CA+B9C;AAED,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,SAAI,UAoCjE;AAmQD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,gBAAgB,CAsBzE;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,UAI7C;AAED,eAAO,MAAM,QAAQ,UAAiB,CAAC"}
|
|
@@ -283,7 +283,7 @@ export class Element extends Node {
|
|
|
283
283
|
this.childNodes = [];
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
-
|
|
286
|
+
_style = new Proxy(
|
|
287
287
|
{},
|
|
288
288
|
{
|
|
289
289
|
get: (state: Record<string, any>, prop: string) => state[prop],
|
|
@@ -300,6 +300,26 @@ export class Element extends Node {
|
|
|
300
300
|
}
|
|
301
301
|
);
|
|
302
302
|
|
|
303
|
+
get style() {
|
|
304
|
+
return this._style as any;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
set style(value: string) {
|
|
308
|
+
if (typeof value === "string") {
|
|
309
|
+
// should match pairs like "color: red; font-size: 12px; background: url(http://example.com/image.png?s=1024x1024&w=is&k=20&c=ASa_AG8uP5Di7azXgJraSA6ME7fbLB0GX4YT_OzCARI=);"
|
|
310
|
+
const regex = /([^:\s]+):\s*((url\([^)]+\))|[^;]+(?=(;|$)))/g;
|
|
311
|
+
let match;
|
|
312
|
+
|
|
313
|
+
while ((match = regex.exec(value)) !== null) {
|
|
314
|
+
this._style[match[1]] = match[2].trim();
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
throw new Error("Cannot set style");
|
|
321
|
+
}
|
|
322
|
+
|
|
303
323
|
classList = {
|
|
304
324
|
toggle: (item: any, force: any) => {
|
|
305
325
|
if (item) {
|
|
@@ -342,6 +362,7 @@ export class Element extends Node {
|
|
|
342
362
|
get innerHTML() {
|
|
343
363
|
let str = "";
|
|
344
364
|
for (let i = 0, l = this.childNodes.length; i < l; i++) {
|
|
365
|
+
// console.log("domToHtml", this.childNodes[i], domToHtml(this.childNodes[i] as Element));
|
|
345
366
|
str += domToHtml(this.childNodes[i] as Element);
|
|
346
367
|
}
|
|
347
368
|
return str;
|
|
@@ -679,10 +700,10 @@ function getObjectIndexTree(html: string): DocumentFragment {
|
|
|
679
700
|
|
|
680
701
|
if (attributesWithValues) {
|
|
681
702
|
for (let attribute of attributesWithValues) {
|
|
682
|
-
const [name, value] = attribute.trim().split("=");
|
|
703
|
+
const [name, ...value] = attribute.trim().split("=");
|
|
683
704
|
string = string.replace(attribute, "");
|
|
684
705
|
if (value) {
|
|
685
|
-
element.attributes[name] = value.replace(/(^"|"$)/g, "");
|
|
706
|
+
element.attributes[name] = value.join("=").replace(/(^"|"$)/g, "");
|
|
686
707
|
}
|
|
687
708
|
}
|
|
688
709
|
}
|
|
@@ -690,10 +711,10 @@ function getObjectIndexTree(html: string): DocumentFragment {
|
|
|
690
711
|
let attributesWithBooleanValues = string.match(/\s\S+=[^"]+/g);
|
|
691
712
|
if (attributesWithBooleanValues) {
|
|
692
713
|
for (let attribute of attributesWithBooleanValues) {
|
|
693
|
-
const [name, value] = attribute.trim().split("=");
|
|
714
|
+
const [name, ...value] = attribute.trim().split("=");
|
|
694
715
|
string = string.replace(attribute, "");
|
|
695
716
|
if (value) {
|
|
696
|
-
element.attributes[name] = value;
|
|
717
|
+
element.attributes[name] = value.join("=").replace(/(^"|"$)/g, "");
|
|
697
718
|
}
|
|
698
719
|
}
|
|
699
720
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "valyrian.js",
|
|
3
|
-
"version": "7.2.
|
|
3
|
+
"version": "7.2.7",
|
|
4
4
|
"description": "Lightweight steel to forge PWAs. (Minimal Frontend Framework with server side rendering and other capabilities)",
|
|
5
5
|
"repository": "git@github.com:Masquerade-Circus/valyrian.js.git",
|
|
6
6
|
"author": "Masquerade <christian@masquerade-circus.net>",
|