diff options
| author | Jeff Cross | 2013-07-24 10:17:24 -0700 | 
|---|---|---|
| committer | Jeff Cross | 2013-08-09 13:14:12 -0700 | 
| commit | 3ee744cc63a24b127d6a5f632934bb6ed2de275a (patch) | |
| tree | d66bab80608d1ef959fd7fd871e9493dad24d928 /src/Angular.js | |
| parent | 94ec84e7b9c89358dc00e4039009af9e287bbd05 (diff) | |
| download | angular.js-3ee744cc63a24b127d6a5f632934bb6ed2de275a.tar.bz2 | |
fix(re-bootstrap): Throw an error when bootstrapping a bootstrapped element.
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 has an injector, and if so, will throw an error.
Diffstat (limited to 'src/Angular.js')
| -rw-r--r-- | src/Angular.js | 6 | 
1 files changed, 6 insertions, 0 deletions
| diff --git a/src/Angular.js b/src/Angular.js index 1a90f8bc..90c7234a 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -1049,6 +1049,12 @@ function angularInit(element, bootstrap) {  function bootstrap(element, modules) {    var doBootstrap = function() {      element = jqLite(element); + +    if (element.injector()) { +      var tag = (element[0] === document) ? 'document' : startingTag(element); +      throw ngMinErr('btstrpd', "App Already Bootstrapped with this Element '{0}'", tag); +    } +      modules = modules || [];      modules.unshift(['$provide', function($provide) {        $provide.value('$rootElement', element); | 
