Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix(isElement): return boolean value rather than truthy value.#4534

Closed
caitp wants to merge 1 commit into
angular:masterfrom
caitp:issue-4519
Closed

fix(isElement): return boolean value rather than truthy value.#4534
caitp wants to merge 1 commit into
angular:masterfrom
caitp:issue-4519

Conversation

@caitp

@caitp caitp commented Oct 19, 2013

Copy link
Copy Markdown
Contributor

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

@mary-poppins

Copy link
Copy Markdown

Thanks for the PR!

  • Contributor signed CLA now or in the past
    • If you just signed, leave a comment here with your real name
  • PR's commit messages follow the commit message format

If you need to make changes to your pull request, you can update the commit with git commit --amend.
Then, update the pull request with git push -f.

Thanks again for your help!

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 angular#4519
@caitp

caitp commented Oct 26, 2013

Copy link
Copy Markdown
Contributor Author

CLA signed previously as Caitlin Potter

@petebacondarwin

Copy link
Copy Markdown
Contributor

@caitp - Is this change really necessary? I mean if you really want to test for equality you can do

!!isElement(e) === someBooleanValue

But I would expect that the vast majority of the time you would be doing

isElement(e) == someBooleanValue

Especially if you know that someBooleanValue really is definitely a boolean.

@caitp

caitp commented Nov 9, 2013

Copy link
Copy Markdown
Contributor Author

@petebacondarwin I tend to agree, it's really just for @gabejohnson and others who want to use the isEqual() / similar strict matchers. You'd have to ask them how big of a deal it is to use strict matchers for boolean-ish expressions.

@jackcviers

Copy link
Copy Markdown
Contributor

Js non-strict equality is a unpopular practice, because it tends to lie.
The rules surrounding truthiness and falsiness are trivia that's easy to
avoid by using strict equality for the average developer, and the type
coercion rules enfoced by == are the source of lots of small, subtle bugs
in production systems. Keeping Booleans Boolean simplifies matters. There
are settings in jshint to support this option.
On Nov 9, 2013 5:47 PM, "Pete Bacon Darwin" notifications@github.com
wrote:

@caitp https://github.com/caitp - Is this change really necessary? I
mean if you really want to test for equality you can do

!!isElement(e) === someBooleanValue

But I would expect that the vast majority of the time you would be doing

isElement(e) == someBooleanValue

Especially if you know that someBooleanValue really is definitely a
boolean.


Reply to this email directly or view it on GitHubhttps://github.com//pull/4534#issuecomment-28139998
.

@IgorMinar IgorMinar closed this in 2dbb6f9 Dec 6, 2013
jamesdaily pushed a commit to jamesdaily/angular.js that referenced this pull request Jan 27, 2014
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 angular#4519
Closes angular#4534
jamesdaily pushed a commit to jamesdaily/angular.js that referenced this pull request Jan 27, 2014
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 angular#4519
Closes angular#4534
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

angular.isElement does not return a boolean

4 participants