Skip to content

Commit

Permalink
Merge pull request #1021 from capricorn86/task/999-innerhtml-parser-i…
Browse files Browse the repository at this point in the history
…nterprets-in-unquoted-element-attributes-incorrectly

#999@patch: Adds support for calc() in CSS values.
  • Loading branch information
capricorn86 authored Aug 18, 2023
2 parents 01fec13 + 38f2e48 commit 9c92c1c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()', () => {
Expand Down

0 comments on commit 9c92c1c

Please sign in to comment.