From 2dbb6f9a54eb5ff5847eed11c85ac4cf119eb41c Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Sat, 19 Oct 2013 15:41:06 -0400 Subject: fix(isElement): return boolean value rather than `truthy` value. angular.isElement currently returns a truthy object/function, or false. This patch aims to correct this behaviour by casting the result of the isElement expression to a boolean value via double-negation. Closes #4519 Closes #4534 --- test/AngularSpec.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test') diff --git a/test/AngularSpec.js b/test/AngularSpec.js index 1b08a18e..36d4926e 100644 --- a/test/AngularSpec.js +++ b/test/AngularSpec.js @@ -1079,4 +1079,17 @@ describe('angular', function() { } }); + describe('isElement', function() { + it('should return a boolean value', inject(function($compile, $document, $rootScope) { + var element = $compile('

Hello, world!

')($rootScope), + body = $document.find('body')[0], + expected = [false, false, false, false, false, false, false, true, true], + tests = [null, undefined, "string", 1001, {}, 0, false, body, element]; + angular.forEach(tests, function(value, idx) { + var result = angular.isElement(value); + expect(typeof result).toEqual('boolean'); + expect(result).toEqual(expected[idx]); + }); + })); + }); }); -- cgit v1.2.3