very strange issue with ng-selected and jquery

Viewed 149

I use AngularJS v1.2.3 and jQuery 1.7.1, the libraries are included in following sort order:

<script type="text/javascript" src="jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="angular.min.js"></script>

The following script works in a strange way, Firebug shows that item #2 has attribute "selected", but I see #1 as selected!

<select ng-app>
        <option value="1" ng-selected="3==1">#1</option>
        <option value="2" ng-selected="2==2">#2</option>
        <option value="3" ng-selected="1==3">#3</option>
</select> 

When I change the sort order of scripts (angularjs before jquery), the code works as expected.

What do I must to do to prevent the issue? I can't change sort order of scripts

Update: This is bug of jQuery 1.7.1:

// See #9699 for explanation of this approach (setting first, then removal)
jQuery.attr( elem, name, "" );

It was fixed later:

// Do not do this for boolean attributes (see #10870)
if ( !isBool ) {
  jQuery.attr( elem, name, "" );
}
1 Answers
Related