Swoogan
Swoogan

Reputation: 5558

ng-mousedown handler attaching to ng-mouseup's event

I am trying to use ng-mousedown and ng-mouseup in concert, however ng-mousedown is firing twice and ng-mouseup is not firing at all. For example, the following code causes count to increment by two instead of going up on press and down on release:

<!DOCTYPE html>
<html>
  <body ng-app>
    <div>
      <div style="background-color: blue; width: 80px;" ng-mousedown="count = count + 1" ng-mouseup="count = count - 1" ng-init="count=0">Click Me</div>
      <div>{{count}}</div>
    </div>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
  </body>
</html>

If I change the Angular version to 1.1.1 it works as expected. Am I doing something wrong or is this a bug in Angular? I've tested in Chrome and Firefox. It works in Firefox, but not Chrome.

Update: After further testing it appears that this may only fail to work in Chrome on Linux 64. So it might be a bug in Chrome.

Upvotes: 1

Views: 1029

Answers (1)

Swoogan
Swoogan

Reputation: 5558

I loaded the test file into Chrome directly and found it worked as expect. When I compared it to the one loaded via my local webserver, I found the following line injected into my HTML:

<div id="__ngBatarangElement" style="display: none;">{"id":1,"time":18.12599998083897,"event":"scope:apply"}</div>

That made me suspect the AngularJS tab in dev tools. Sure enough, disabling it "fixed" the page:

Batarang Fail

What is more disconcerting is the fact that I distinctly remember choosing not to install Batarang due to the nearly universal negative reviews. I guess I will have to add mine to the pile.

Update: Found that the issue has been reported https://github.com/angular/angularjs-batarang/issues/205

Upvotes: 2

Related Questions