happy-dom 10.3.2 → 10.5.0
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.
Potentially problematic release.
This version of happy-dom might be problematic. Click here for more details.
- package/cjs/css/CSSParser.cjs +4 -1
- package/cjs/css/CSSParser.cjs.map +1 -1
- package/cjs/css/CSSParser.d.ts.map +1 -1
- package/cjs/css/declaration/css-parser/CSSStyleDeclarationCSSParser.cjs +9 -15
- package/cjs/css/declaration/css-parser/CSSStyleDeclarationCSSParser.cjs.map +1 -1
- package/cjs/css/declaration/css-parser/CSSStyleDeclarationCSSParser.d.ts.map +1 -1
- package/cjs/css/declaration/property-manager/CSSStyleDeclarationPropertySetParser.cjs +6 -5
- package/cjs/css/declaration/property-manager/CSSStyleDeclarationPropertySetParser.cjs.map +1 -1
- package/cjs/css/declaration/property-manager/CSSStyleDeclarationPropertySetParser.d.ts.map +1 -1
- package/cjs/event/events/IMouseEventInit.d.ts +2 -0
- package/cjs/event/events/IMouseEventInit.d.ts.map +1 -1
- package/cjs/event/events/MouseEvent.cjs +2 -0
- package/cjs/event/events/MouseEvent.cjs.map +1 -1
- package/cjs/event/events/MouseEvent.d.ts.map +1 -1
- package/lib/css/CSSParser.d.ts.map +1 -1
- package/lib/css/CSSParser.js +4 -1
- package/lib/css/CSSParser.js.map +1 -1
- package/lib/css/declaration/css-parser/CSSStyleDeclarationCSSParser.d.ts.map +1 -1
- package/lib/css/declaration/css-parser/CSSStyleDeclarationCSSParser.js +9 -15
- package/lib/css/declaration/css-parser/CSSStyleDeclarationCSSParser.js.map +1 -1
- package/lib/css/declaration/property-manager/CSSStyleDeclarationPropertySetParser.d.ts.map +1 -1
- package/lib/css/declaration/property-manager/CSSStyleDeclarationPropertySetParser.js +6 -5
- package/lib/css/declaration/property-manager/CSSStyleDeclarationPropertySetParser.js.map +1 -1
- package/lib/event/events/IMouseEventInit.d.ts +2 -0
- package/lib/event/events/IMouseEventInit.d.ts.map +1 -1
- package/lib/event/events/MouseEvent.d.ts.map +1 -1
- package/lib/event/events/MouseEvent.js +2 -0
- package/lib/event/events/MouseEvent.js.map +1 -1
- package/package.json +1 -1
- package/src/css/CSSParser.ts +4 -1
- package/src/css/declaration/css-parser/CSSStyleDeclarationCSSParser.ts +11 -17
- package/src/css/declaration/property-manager/CSSStyleDeclarationPropertySetParser.ts +6 -5
- package/src/event/events/IMouseEventInit.ts +2 -0
- package/src/event/events/MouseEvent.ts +2 -0
@@ -1,3 +1,10 @@
|
|
1
|
+
// PropName => \s*([^:;]+?)\s*:
|
2
|
+
// PropValue => \s*((?:[^(;]*?(?:\([^)]*\))?)*?) <- will match any non ';' char except inside (), nested parentheses are not supported
|
3
|
+
// !important => \s*(!important)?
|
4
|
+
// EndOfRule => \s*(?:$|;)
|
5
|
+
const SPLIT_RULES_REGEXP =
|
6
|
+
/\s*([^:;]+?)\s*:\s*((?:[^(;]*?(?:\([^)]*\))?)*?)\s*(!important)?\s*(?:$|;)/g;
|
7
|
+
|
1
8
|
/**
|
2
9
|
* CSS parser.
|
3
10
|
*/
|
@@ -12,23 +19,10 @@ export default class CSSStyleDeclarationCSSParser {
|
|
12
19
|
cssText: string,
|
13
20
|
callback: (name: string, value: string, important: boolean) => void
|
14
21
|
): void {
|
15
|
-
const
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
const [name, value]: string[] = part.trim().split(':');
|
20
|
-
if (value) {
|
21
|
-
const trimmedName = name.trim();
|
22
|
-
const trimmedValue = value.trim();
|
23
|
-
if (trimmedName && trimmedValue) {
|
24
|
-
const important = trimmedValue.endsWith(' !important');
|
25
|
-
const valueWithoutImportant = trimmedValue.replace(' !important', '');
|
26
|
-
|
27
|
-
if (valueWithoutImportant) {
|
28
|
-
callback(trimmedName, valueWithoutImportant, important);
|
29
|
-
}
|
30
|
-
}
|
31
|
-
}
|
22
|
+
const rules = Array.from(cssText.matchAll(SPLIT_RULES_REGEXP));
|
23
|
+
for (const [, key, value, important] of rules) {
|
24
|
+
if (key && value) {
|
25
|
+
callback(key.trim(), value.trim(), !!important);
|
32
26
|
}
|
33
27
|
}
|
34
28
|
}
|
@@ -2,6 +2,7 @@ import CSSStyleDeclarationValueParser from './CSSStyleDeclarationValueParser.js'
|
|
2
2
|
import ICSSStyleDeclarationPropertyValue from './ICSSStyleDeclarationPropertyValue.js';
|
3
3
|
|
4
4
|
const RECT_REGEXP = /^rect\((.*)\)$/i;
|
5
|
+
const SPLIT_PARTS_REGEXP = /,(?=(?:(?:(?!\))[\s\S])*\()|[^\(\)]*$)/; // Split on commas that are outside of parentheses
|
5
6
|
const BORDER_STYLE = [
|
6
7
|
'none',
|
7
8
|
'hidden',
|
@@ -2383,7 +2384,7 @@ export default class CSSStyleDeclarationPropertySetParser {
|
|
2383
2384
|
return { 'background-size': { value: lowerValue, important } };
|
2384
2385
|
}
|
2385
2386
|
|
2386
|
-
const imageParts = lowerValue.split(
|
2387
|
+
const imageParts = lowerValue.split(SPLIT_PARTS_REGEXP);
|
2387
2388
|
const parsed = [];
|
2388
2389
|
|
2389
2390
|
for (const imagePart of imageParts) {
|
@@ -2554,7 +2555,7 @@ export default class CSSStyleDeclarationPropertySetParser {
|
|
2554
2555
|
};
|
2555
2556
|
}
|
2556
2557
|
|
2557
|
-
const imageParts = value.
|
2558
|
+
const imageParts = value.split(SPLIT_PARTS_REGEXP);
|
2558
2559
|
let x = '';
|
2559
2560
|
let y = '';
|
2560
2561
|
|
@@ -2667,7 +2668,7 @@ export default class CSSStyleDeclarationPropertySetParser {
|
|
2667
2668
|
return { 'background-position-x': { value: lowerValue, important } };
|
2668
2669
|
}
|
2669
2670
|
|
2670
|
-
const imageParts = lowerValue.
|
2671
|
+
const imageParts = lowerValue.split(SPLIT_PARTS_REGEXP);
|
2671
2672
|
let parsedValue = '';
|
2672
2673
|
|
2673
2674
|
for (const imagePart of imageParts) {
|
@@ -2718,7 +2719,7 @@ export default class CSSStyleDeclarationPropertySetParser {
|
|
2718
2719
|
return { 'background-position-y': { value: lowerValue, important } };
|
2719
2720
|
}
|
2720
2721
|
|
2721
|
-
const imageParts = lowerValue.
|
2722
|
+
const imageParts = lowerValue.split(SPLIT_PARTS_REGEXP);
|
2722
2723
|
let parsedValue = '';
|
2723
2724
|
|
2724
2725
|
for (const imagePart of imageParts) {
|
@@ -2794,7 +2795,7 @@ export default class CSSStyleDeclarationPropertySetParser {
|
|
2794
2795
|
return { 'background-image': { value: lowerValue, important } };
|
2795
2796
|
}
|
2796
2797
|
|
2797
|
-
const parts = value.
|
2798
|
+
const parts = value.split(SPLIT_PARTS_REGEXP);
|
2798
2799
|
const parsed = [];
|
2799
2800
|
|
2800
2801
|
for (const part of parts) {
|
@@ -40,6 +40,8 @@ export default class MouseEvent extends UIEvent {
|
|
40
40
|
this.clientY = eventInit.clientY !== undefined ? eventInit.clientY : 0;
|
41
41
|
this.ctrlKey = eventInit.ctrlKey || false;
|
42
42
|
this.metaKey = eventInit.metaKey || false;
|
43
|
+
this.movementX = eventInit.movementX || 0;
|
44
|
+
this.movementY = eventInit.movementY || 0;
|
43
45
|
this.region = eventInit.region || '';
|
44
46
|
this.relatedTarget = eventInit.relatedTarget || null;
|
45
47
|
this.screenX = eventInit.screenX !== undefined ? eventInit.screenX : 0;
|