From 1bd1a97d7d22921e2cfb1fcb940f485a095130f8 Mon Sep 17 00:00:00 2001 From: Michael Prentice Date: Wed, 17 Jun 2020 03:07:48 -0400 Subject: [PATCH] fix(layout): Syntax Error: Token '&&' not a primary expression - revert change to not set `origValue` - this was always checking against `undefined` Fixes #10935 --- src/core/services/layout/layout.js | 2 +- src/core/services/layout/layout.spec.js | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/core/services/layout/layout.js b/src/core/services/layout/layout.js index 7074ce31c98..13a89723fe4 100644 --- a/src/core/services/layout/layout.js +++ b/src/core/services/layout/layout.js @@ -407,7 +407,7 @@ * fallback value */ function validateAttributeValue(className, value, updateFn) { - var origValue; + var origValue = value; if (!needsInterpolation(value)) { switch (className.replace(SUFFIXES,"")) { diff --git a/src/core/services/layout/layout.spec.js b/src/core/services/layout/layout.spec.js index 1d9c5b144af..9be39aae7b9 100644 --- a/src/core/services/layout/layout.spec.js +++ b/src/core/services/layout/layout.spec.js @@ -1,3 +1,12 @@ +// AngularJS Component test setup +angular.module('layoutTestApp', []) +.component('testComponent', { + bindings: { + show: '=', + }, + controller: function() {} +}); + describe("Layout API ", function() { describe("can be globally disabled with 'md-layouts-disabled' ", function() { @@ -46,6 +55,7 @@ describe("Layout API ", function() { var suffixes = ['xs', 'gt-xs', 'sm', 'gt-sm', 'md', 'gt-md', 'lg', 'gt-lg', 'xl', 'print'], $mdUtil, $compile, pageScope; + beforeEach(module('layoutTestApp')); beforeEach(inject(function(_$compile_, _$rootScope_, _$mdUtil_) { $mdUtil = _$mdUtil_; $compile = _$compile_; @@ -298,6 +308,13 @@ describe("Layout API ", function() { testNoValueAllowed(className); }); + it('should not throw Token \'&&\' not a primary expression', inject(function($rootScope, $compile) { + var scope = pageScope; + scope.left = true; + scope.right = true; + var element = angular.element($compile('')(scope)); + expect(element.attr('show')).toBe('left && right'); + })); }); // *****************************************************************