-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix(re-bootstrap): Throw an error when bootstrapping a bootstrapped element #3411
Conversation
|
||
var classes = element.attr('class'); | ||
var SCOPE_CLASS = /([^A-Za-z0-9\-\_]ng\-scope|^ng\-scope)(?!\S)/; | ||
if (SCOPE_CLASS.test(classes)) throw ngMinErr('btstrpd', "Element '{0}' is already bootstrapped", element[0].outerHTML); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace with
if (!angular.injector()) throw
@mhevery I get odd behavior when I use element.injector() to determine if an element has already been bootstrapped. This line causes all e2e tests to fail.
If I change |
@@ -0,0 +1,4 @@ | |||
@ngdoc error | |||
@name ng:btstrpd | |||
@fullName Element Already Bootstrapped |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we say "App Already Bootstrapped with this Element" instead? "bootstrapping and element" doesn't make much sense to me.
This is necessary to make e2e tests pass for implementing angular#3411. At present, the docs are violating the rule being enforced by double-bootstrap prevention.
Note this PR is rebased against the branch from #3458, because tests require a fix from that branch. Once that PR gets merged, this PR will be down to one commit. |
This is necessary to make e2e tests pass for implementing #3411. At present, the docs are violating the rule being enforced by double-bootstrap prevention.
CI is happy: http://ci.angularjs.org/job/angular.js-jeff/41/ |
…lement. Nothing would prevent a user from accidentally calling angular.bootstrap on an element that had already been bootstrapped. If this was done, odd behavior could manifest in an application, causing different scopes to update the same DOM, and causing debugger confusion. This fix adds a check inside of angular.bootstrap to check if the passed-in element already contains a class of ng-scope, and if so, will throw an error.
I just upgraded the Angular to 1.2.8. I am initializing and opening a model from GWT using $wnd.angular.bootstrap($doc, ['fmEventLogApp']); After closing the model, when I try to open the model again, it is try to reinitialize the model again and it is throwing an error as "uncaught exception: com.google.gwt.event.shared.UmbrellaException: One or more exceptions caught, see full set in UmbrellaException#getCauses" But when i see the error message, it says "App Already Bootstrapped with this Element". How to solve this problem in case of a model window? Please help. |
Are you manually calling angular.bootstrap somewhere in the process of opening the modal? Or is the ng-app directive being used inside the modal? Either of these behaviors would cause the problem. |
Inside my GWT code, I am using $wnd.angular.bootstrap to open the modal. Other than this, I am not using angular.bootstrap or ng-app directive. This might be fixed differently by using the modal injector which is returned by the angular.bootstrap, I think. Going to try that now. |
Nothing would prevent a user from accidentally calling angular.bootstrap on an element that had already been bootstrapped. If this was done, odd behavior could manifest in an application, causing different scopes to update the same DOM, and causing debugger confusion.
This fix adds a check inside of angular.bootstrap to check if the passed-in element already contains a class of ng-scope, and if so, will throw an error.