diff --git a/packages/happy-dom/src/css/declaration/property-manager/CSSStyleDeclarationValueParser.ts b/packages/happy-dom/src/css/declaration/property-manager/CSSStyleDeclarationValueParser.ts index bc9ff1b1b..d05a8008d 100644 --- a/packages/happy-dom/src/css/declaration/property-manager/CSSStyleDeclarationValueParser.ts +++ b/packages/happy-dom/src/css/declaration/property-manager/CSSStyleDeclarationValueParser.ts @@ -262,7 +262,7 @@ export default class CSSStyleDeclarationValueParser { * @returns Parsed value. */ public static getMeasurement(value: string): string { - return this.getLength(value) || this.getPercentage(value); + return this.getLength(value) || this.getPercentage(value) || this.getCalc(value); } /** diff --git a/packages/happy-dom/test/css/declaration/CSSStyleDeclaration.test.ts b/packages/happy-dom/test/css/declaration/CSSStyleDeclaration.test.ts index 8f13e7216..0b4281e70 100644 --- a/packages/happy-dom/test/css/declaration/CSSStyleDeclaration.test.ts +++ b/packages/happy-dom/test/css/declaration/CSSStyleDeclaration.test.ts @@ -2103,6 +2103,14 @@ describe('CSSStyleDeclaration', () => { expect(declaration.width).toBe('0px'); }); + + it('Returns width for "width: calc(10% - 1px)".', () => { + const declaration = new CSSStyleDeclaration(element); + + element.setAttribute('style', 'width: calc(10% - 1px)'); + + expect(declaration.width).toBe('calc(10% - 1px)'); + }); }); describe('get height()', () => {