diff --git a/packages/core/src/render3/styling/styling_parser.ts b/packages/core/src/render3/styling/styling_parser.ts index de80259bc1..8407476743 100644 --- a/packages/core/src/render3/styling/styling_parser.ts +++ b/packages/core/src/render3/styling/styling_parser.ts @@ -210,7 +210,8 @@ export function consumeStyleKey(text: string, startIndex: number, endIndex: numb let ch: number; while (startIndex < endIndex && ((ch = text.charCodeAt(startIndex)) === CharCode.DASH || ch === CharCode.UNDERSCORE || - ((ch & CharCode.UPPER_CASE) >= CharCode.A && (ch & CharCode.UPPER_CASE) <= CharCode.Z))) { + ((ch & CharCode.UPPER_CASE) >= CharCode.A && (ch & CharCode.UPPER_CASE) <= CharCode.Z) || + (ch >= CharCode.ZERO && ch <= CharCode.NINE))) { startIndex++; } return startIndex; diff --git a/packages/core/src/util/char_code.ts b/packages/core/src/util/char_code.ts index 7815358d74..6680ebacad 100644 --- a/packages/core/src/util/char_code.ts +++ b/packages/core/src/util/char_code.ts @@ -22,6 +22,8 @@ export const enum CharCode { SEMI_COLON = 59, // ";" BACK_SLASH = 92, // "\\" AT_SIGN = 64, // "@" + ZERO = 48, // "0" + NINE = 57, // "9" A = 65, // "A" U = 85, // "U" R = 82, // "R" diff --git a/packages/core/test/acceptance/styling_spec.ts b/packages/core/test/acceptance/styling_spec.ts index 8431c9b79e..bea42b397c 100644 --- a/packages/core/test/acceptance/styling_spec.ts +++ b/packages/core/test/acceptance/styling_spec.ts @@ -214,28 +214,51 @@ describe('styling', () => { }); }); - describe('css variables', () => { - onlyInIvy('css variables').it('should support css variables', () => { + onlyInIvy('CSS variables are only supported in Ivy').describe('css variables', () => { + const supportsCssVariables = typeof getComputedStyle !== 'undefined' && + typeof CSS !== 'undefined' && typeof CSS.supports !== 'undefined' && + CSS.supports('color', 'var(--fake-var)'); + + it('should support css variables', () => { // This test only works in browsers which support CSS variables. - if (!(typeof getComputedStyle !== 'undefined' && typeof CSS !== 'undefined' && - typeof CSS.supports !== 'undefined' && CSS.supports('color', 'var(--fake-var)'))) + if (!supportsCssVariables) { return; + } + @Component({ template: ` -