Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
fix(layout): Syntax Error: Token '&&' not a primary expression
Browse files Browse the repository at this point in the history
- revert change to not set `origValue`
- this was always checking against `undefined`

Fixes #10935
  • Loading branch information
Splaktar committed Jun 17, 2020
1 parent 08313be commit 1bd1a97
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/services/layout/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@
* fallback value
*/
function validateAttributeValue(className, value, updateFn) {
var origValue;
var origValue = value;

if (!needsInterpolation(value)) {
switch (className.replace(SUFFIXES,"")) {
Expand Down
17 changes: 17 additions & 0 deletions src/core/services/layout/layout.spec.js
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down Expand Up @@ -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_;
Expand Down Expand Up @@ -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('<test-component show="left && right"></test-component>')(scope));
expect(element.attr('show')).toBe('left && right');
}));
});

// *****************************************************************
Expand Down

0 comments on commit 1bd1a97

Please sign in to comment.