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. --- test/AngularSpec.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'test') diff --git a/test/AngularSpec.js b/test/AngularSpec.js index 56fc985c..f049c2fd 100644 --- a/test/AngularSpec.js +++ b/test/AngularSpec.js @@ -656,6 +656,32 @@ describe('angular', function() { /\[\$injector:modulerr] Failed to instantiate module doesntexist due to:\n.*\[\$injector:nomod] Module 'doesntexist' is not available! You either misspelled the module name or forgot to load it\./ ); }); + + + it('should complain if an element has already been bootstrapped', function () { + var element = jqLite('