From 3ee744cc63a24b127d6a5f632934bb6ed2de275a Mon Sep 17 00:00:00 2001 From: Jeff Cross Date: Wed, 24 Jul 2013 10:17:24 -0700 Subject: 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. --- src/Angular.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/Angular.js') 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); -- cgit v1.2.3