Skip to content

Commit d4f9436

Browse files
authored
refactor(tests): move parser tests from qunit to vitest (fabricjs#10542)
1 parent 4a3d4f1 commit d4f9436

11 files changed

+848
-834
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## [next]
44

5+
- refactor(tests): move parser tests from qunit to vitest [#10542](https://github.com/fabricjs/fabric.js/pull/10542)
56
- refactor(tests): move intersection tests from qunit to vitest [#10541](https://github.com/fabricjs/fabric.js/pull/10541)
67
- refactor(tests): move Text.toSVG tests from qunit to vitest [#10540](https://github.com/fabricjs/fabric.js/pull/10540)
78
- refactor(tests): move object geometry tests from qunit to vitest [#10539](https://github.com/fabricjs/fabric.js/pull/10539)

fabric.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ export { config } from './src/config';
55
export { classRegistry } from './src/ClassRegistry';
66
export { runningAnimations } from './src/util/animation/AnimationRegistry';
77

8-
export * from './src/typedefs';
8+
export type * from './src/typedefs';
99

10-
export * from './src/EventTypeDefs';
10+
export type * from './src/EventTypeDefs';
1111
export type { ITextEvents } from './src/shapes/IText/ITextBehavior';
1212

1313
export { Observable } from './src/Observable';
@@ -28,15 +28,15 @@ export { Point } from './src/Point';
2828
export type { IntersectionType } from './src/Intersection';
2929
export { Intersection } from './src/Intersection';
3030
export { Color } from './src/color/Color';
31-
export * from './src/color/typedefs';
31+
export type * from './src/color/typedefs';
3232

3333
export * from './src/gradient';
3434
export * from './src/Pattern';
3535
export { Shadow } from './src/Shadow';
3636
export type { SerializedShadowOptions } from './src/Shadow';
3737

3838
export { BaseBrush } from './src/brushes/BaseBrush';
39-
export * from './src/brushes/typedefs';
39+
export type * from './src/brushes/typedefs';
4040

4141
export { PencilBrush } from './src/brushes/PencilBrush';
4242
export { CircleBrush } from './src/brushes/CircleBrush';

src/parser/doesSomeParentMatch.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { selectorMatches } from './selectorMatches';
22

3-
export function doesSomeParentMatch(element: HTMLElement, selectors: string[]) {
3+
export function doesSomeParentMatch(
4+
element: HTMLElement | SVGElement,
5+
selectors: string[],
6+
) {
47
let selector: string,
58
parentMatching = true;
69
while (

src/parser/elementMatchesRule.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import { doesSomeParentMatch } from './doesSomeParentMatch';
55
* @private
66
*/
77

8-
export function elementMatchesRule(element: HTMLElement, selectors: string[]) {
8+
export function elementMatchesRule(
9+
element: HTMLElement | SVGElement,
10+
selectors: string[],
11+
) {
912
let parentMatching = true;
1013
// start from rightmost selector.
1114
const firstMatching = selectorMatches(element, selectors.pop()!);

src/parser/getGlobalStylesForElement.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { CSSRules } from './typedefs';
66
*/
77

88
export function getGlobalStylesForElement(
9-
element: HTMLElement,
9+
element: HTMLElement | SVGElement,
1010
cssRules: CSSRules = {},
1111
) {
1212
let styles: Record<string, string> = {};

src/parser/parseAttributes.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import type { CSSRules } from './typedefs';
1717
* @return {Object} object containing parsed attributes' names/values
1818
*/
1919
export function parseAttributes(
20-
element: HTMLElement | null,
20+
element: HTMLElement | SVGElement | null,
2121
attributes: string[],
2222
cssRules?: CSSRules,
2323
): Record<string, any> {

src/parser/parseStyleAttribute.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import { parseStyleString } from './parseStyleString';
88
* @param {SVGElement} element Element to parse
99
* @return {Object} Objects with values parsed from style attribute of an element
1010
*/
11-
export function parseStyleAttribute(element: HTMLElement): Record<string, any> {
11+
export function parseStyleAttribute(
12+
element: HTMLElement | SVGElement,
13+
): Record<string, any> {
1214
const oStyle: Record<string, any> = {},
1315
style = element.getAttribute('style');
1416

0 commit comments

Comments
 (0)