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

[Breaking] 1.6.0 ng-class form bind causes [ng:cpws] Can't copy! Making copies of Window or Scope instances is not supported. #15479

Closed
niemyjski opened this issue Dec 8, 2016 · 7 comments

Comments

@niemyjski
Copy link

I have async validation (https://github.com/exceptionless/Exceptionless.UI/blob/master/src/app/auth/signup.tpl.html#L59) happening in this form and if I remove it it works, If I leave it but remove the following ng-bind it also works (https://github.com/exceptionless/Exceptionless.UI/blob/master/src/app/auth/signup.tpl.html#L54). There is some kind of issue going on here and I figured I'd log this and continue to try and track it down.

The code can all be found here: https://github.com/exceptionless/exceptionless.ui

angular.js:14324 Error: [ng:cpws] Can't copy! Making copies of Window or Scope instances is not supported.
http://errors.angularjs.org/1.6.0/ng/cpws
    at http://localhost:9001/bower_components/angular/angular.js:68:12
    at copyElement (http://localhost:9001/bower_components/angular/angular.js:993:13)
    at copyRecurse (http://localhost:9001/bower_components/angular/angular.js:965:30)
    at copyElement (http://localhost:9001/bower_components/angular/angular.js:1009:9)
    at copyRecurse (http://localhost:9001/bower_components/angular/angular.js:954:26)
    at copyElement (http://localhost:9001/bower_components/angular/angular.js:1009:9)
    at copyRecurse (http://localhost:9001/bower_components/angular/angular.js:965:30)
    at copyElement (http://localhost:9001/bower_components/angular/angular.js:1009:9)
    at copyRecurse (http://localhost:9001/bower_components/angular/angular.js:965:30)
    at copyElement (http://localhost:9001/bower_components/angular/angular.js:1009:9)
    at copyRecurse (http://localhost:9001/bower_components/angular/angular.js:954:26)
    at copyElement (http://localhost:9001/bower_components/angular/angular.js:1009:9)
    at copyRecurse (http://localhost:9001/bower_components/angular/angular.js:965:30)
    at copyElement (http://localhost:9001/bower_components/angular/angular.js:1009:9)
    at copyRecurse (http://localhost:9001/bower_components/angular/angular.js:965:30)
    at copyElement (http://localhost:9001/bower_components/angular/angular.js:1009:9)
    at copy (http://localhost:9001/bower_components/angular/angular.js:947:10)
    at Scope.$digest (http://localhost:9001/bower_components/angular/angular.js:17798:47)
    at Scope.$apply (http://localhost:9001/bower_components/angular/angular.js:18066:24)
    at Object.$$debounceViewValueCommit (http://localhost:9001/bower_components/angular/angular.js:28548:20)
    at Object.$setViewValue (http://localhost:9001/bower_components/angular/angular.js:28526:12)
    at HTMLInputElement.listener (http://localhost:9001/bower_components/angular/angular.js:24528:12)
    at HTMLInputElement.dispatch (http://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js:3:10315)
    at HTMLInputElement.q.handle (http://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js:3:8342)
    at Scope.$apply (http://localhost:9001/bower_components/angular/angular.js:18070:13)
    at http://localhost:9001/bower_components/angular/angular.js:19910:36
    at completeOutstandingRequest (http://localhost:9001/bower_components/angular/angular.js:6108:10)
    at http://localhost:9001/bower_components/angular/angular.js:6387:7 undefined
(anonymous) @ angular.js:14324
$delegate.(anonymous function) @ angular.js:36
(anonymous) @ angular.js:10834
(anonymous) @ angulartics.js:379
(anonymous) @ angular.js:25
$digest @ angular.js:17818
$apply @ angular.js:18066
$$debounceViewValueCommit @ angular.js:28548
$setViewValue @ angular.js:28526
listener @ angular.js:24528
dispatch @ jquery.min.js:3
q.handle @ jquery.min.js:3
$apply @ angular.js:18070
(anonymous) @ angular.js:19910
completeOutstandingRequest @ angular.js:6108
(anonymous) @ angular.js:6387

This happens 10 times and then I get:

angular.js:14324 Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: []
http://errors.angularjs.org/1.6.0/$rootScope/infdig?p0=10&p1=%5B%5D
    at http://localhost:9001/bower_components/angular/angular.js:68:12
    at Scope.$digest (http://localhost:9001/bower_components/angular/angular.js:17838:19)
    at Scope.$apply (http://localhost:9001/bower_components/angular/angular.js:18066:24)
    at Object.$$debounceViewValueCommit (http://localhost:9001/bower_components/angular/angular.js:28548:20)
    at Object.$setViewValue (http://localhost:9001/bower_components/angular/angular.js:28526:12)
    at HTMLInputElement.listener (http://localhost:9001/bower_components/angular/angular.js:24528:12)
    at HTMLInputElement.dispatch (http://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js:3:10315)
    at HTMLInputElement.q.handle (http://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js:3:8342)
    at Scope.$apply (http://localhost:9001/bower_components/angular/angular.js:18070:13)
    at http://localhost:9001/bower_components/angular/angular.js:19910:36
    at completeOutstandingRequest (http://localhost:9001/bower_components/angular/angular.js:6108:10)
    at http://localhost:9001/bower_components/angular/angular.js:6387:7 undefined
@gkalpak
Copy link
Member

gkalpak commented Dec 8, 2016

@niemyjski, is this something that used to work before 1.6.0?
Also, can you try the followig two things and let me know if they work:

  1. Change ng-class="{'input-group': vm.signupForm.$pending }" to ng-class="{'input-group': !!vm.signupForm.$pending }".
  2. Try the patch from ngClass[Odd/Even] overhaul (2) #15246.

(Hopefully, both should solve the issue.)

@niemyjski
Copy link
Author

niemyjski commented Dec 8, 2016

Just changing 1. fixed the issue.

@gkalpak
Copy link
Member

gkalpak commented Dec 9, 2016

Good to know 😃 Doing that in all similar places will also improve performance (according to #15243 it will speed up those ngClass instances by a factor of 100(!) if you are using complex objects). Once #15246 will be merged (pretty soon now that 1.6.0 has been released), you won't need to add !!, since this will be optimized by ngClass under the hood.

Now, the critical question is:
Was the original issue introduced in 1.6 or does it also appear on 1.5.x?

@niemyjski
Copy link
Author

niemyjski commented Dec 9, 2016 via email

@gkalpak
Copy link
Member

gkalpak commented Dec 9, 2016

Ooops, sounds like a regression. Any chance you could create a reproduction (e.g. using CodePen, Plnkr etc)?

BTW, it would be awesome if you could test with https://code.angularjs.org/snapshot/angular.js and verify that you no longer need the !!?

@gkalpak
Copy link
Member

gkalpak commented Dec 15, 2016

Since #15246 has landed on 1.6.x and it eliminates copying to very basic objects (not containing scopes or windows), I am pretty confident this will be solved in 1.6.1. (You can try this before 1.6.1 is released using https://code.angularjs.org/snapshot/angular.js.)

Closing as fixed, but feel free to prove me wrong 😃

@davyarris
Copy link

FYI I have had this issue in Angularjs 1.8.2:

I had the following attribute:

ng-class="{'opened': status.isDocumentsOpen}"

and fixed the error by changing to:

ng-class="{'opened': !!status.isDocumentsOpen}"

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants