batarang icon indicating copy to clipboard operation
batarang copied to clipboard

Breaks manually bootstrapped apps (does not return $injector)

Open kentcdodds opened this issue 11 years ago • 13 comments

I'm not sure how this happens, but if you open this jsbin output in a browser without the extension (or an older version) then it works just fine. If you open it with 0.5.0, it doesn't bootstrap and there's an error in the console.

This example seems to be failing for a different reason that my app, but in both cases, angular.bootstrap is returning undefined instead of $injector as it should.

kentcdodds avatar Dec 10 '14 04:12 kentcdodds

I think this is actually two separate issues:

  1. Batarang is having trouble with controller as
  2. angular.bootstrap isn't returning the $injector as it should when batarang is installed.

kentcdodds avatar Dec 10 '14 05:12 kentcdodds

  1. should be fixed in https://github.com/angular/angular-hint-controllers/commit/c354d2945faabcfd716a9c18ae633068cedcc475 and batarang v0.6.0.

btford avatar Dec 10 '14 05:12 btford

Working on a fix for for second point

btford avatar Dec 10 '14 05:12 btford

I don't know if it helps, but from the investigations we have done at my company, we found that it seems Batarang alters window.name. At least if you set a breakpoint on row 1393 in the bootstrap function in angular.js (v1.2.15), you get different values for window.name depending on whether Batarang is enabled or not. The contents of the row is if (window && !NG_DEFER_BOOTSTRAP.test(window.name)) {

With Batarang enabled: window.name = "NG_DEFER_BOOTSTRAP!" With Batarang disabled: window.name = "" (empty)

The not empty window name makes the if-statement evaluate to false which means the doBootstrap() function never runs and consequently the $injector is never returned

marols avatar Dec 10 '14 15:12 marols

@marols – thank you for including this information.

I'm aware that the issue is that deferred bootstrap doesn't return the injector as expected. Working on a fix now.

btford avatar Dec 10 '14 19:12 btford

+1

  1. angular.bootstrap isn't returning the $injector as it should when batarang is installed.

AngularJS Batarang 0.7.4

bzitzow avatar Jan 07 '15 18:01 bzitzow

@kentcdodds provided this JSBin repo: http://output.jsbin.com/wehufa

SomeKittens avatar Sep 24 '15 18:09 SomeKittens

Just realized that the original had a jsbin as well that reproduces the issue :-)

kentcdodds avatar Sep 24 '15 19:09 kentcdodds

Do we know how to fix this issue?

TombolaShepless avatar Sep 30 '15 18:09 TombolaShepless

This appears to happen with all defers of bootstrapping, not just Batarang: http://jsbin.com/silaji/edit?html,js,output

Digging through Angular.js proper to see if there's a solution there.

SomeKittens avatar Sep 30 '15 21:09 SomeKittens

From the docs:

Note that Protractor based end-to-end tests cannot use this function to bootstrap manually. They must use ngApp.

Batarang uses the same techniques as Protractor, so this is a limitation of Angular itself. Sorry about that folks...

SomeKittens avatar Sep 30 '15 21:09 SomeKittens

Huh... That explains why my protractor tests act funny sometimes :-) I think that I'll have to rewrite my bootstrap to do something like this then. :-( Thanks for the tip!

kentcdodds avatar Oct 01 '15 04:10 kentcdodds

@kentcdodds still does not work for me with Meteor. It seems to be closed there too as a limitation https://github.com/Urigo/angular-meteor/issues/90

trajano avatar Mar 13 '16 22:03 trajano