angular / batarang

AngularJS WebInspector Extension for Chrome
MIT License
2.43k stars 338 forks source link

Batarang makes one-time binding to stop working at times #209

Closed walter-psjr closed 9 years ago

walter-psjr commented 9 years ago

I am developing an application where angular realized that the number of watchers was high despite being using one-time binding. I created a test page with a listing in table and realized that when I use http: // localhost one-time binding does not work and when I change the address for the machine name, for example, works correctly:

http://localhost/angular/repeater2.html image

http://ucb-walterdev/angular/repeater2.html image

The detail is that this is only happening in Chrome (I'm using version 39.0.2171.99 m, Windows 8.1 64-bit). In Firefox and Internet Explorer rendering occurs perfectly.

The code to generate the table:

    <table class="table table-bordered table-striped table-hover tablesorter" id="tblOcuppation">
        <thead>
            <tr>
                <th>Id</th>
                <th>Occupation Name</th>
                <th>Delete</th>
            </tr>
        </thead>
        <tbody>
            <tr data-ng-repeat="occupation in occupations">
                <td>{{::occupation.Id}}</td>
                <td>{{::occupation.Name}}</td>
                <td>
                    <button type="button" class="btn btn-default btn-sm" data-ng-show="::occupation.Name.indexOf('a') > -1" data-ng-click="delete(occupation.Id)">
                        <span class="glyphicon glyphicon-trash"></span>
                    </button>
                </td>
            </tr>
        </tbody>
        <tfoot>
            <tr>
                <td>Total:</td>
                <td>{{occupations.length}}</td>
                <td></td>
            </tr>
        </tfoot>
    </table>

Disabling the Batarang extension the one-time binding works normally.

ravishivt commented 9 years ago

+1

erwinmombay commented 9 years ago

can you confirm that this is still a problem? trying to replicate this problem in isolation/reduction right now.

SomeKittens commented 9 years ago

@erwinmombay Uncomment the HTML here to see it in action: https://github.com/angular/angular-hint/blob/master/examples/profile.html#L22

erwinmombay commented 9 years ago

thanks @SomeKittens looks like this might be caused because of us patching $watch and wrapping the original expression with a function and passing that function on to the original $watch. the original $watch can no longer determine that it is a one time binding or a constant binding since we've eval'd it already. Will explore further to prove and will try some solutions.

erwinmombay commented 9 years ago

@SomeKittens per the meeting, i'll go ahead and add code to skip any performance measurement on one time binding expressions to fix this problem and file a ticket with angular/angular.js.

SomeKittens commented 9 years ago

Great! We can close this once the PR is in to angular-hint (and link to the angular.js issue here if you can)

erwinmombay commented 9 years ago

got it. will work on this tomorrow morning and the weekend.

SomeKittens commented 9 years ago

Fixed in latest, should be released with 0.8.0