angular / batarang

AngularJS WebInspector Extension for Chrome
MIT License
2.43k stars 338 forks source link

build 1.5.0-build.4376+sha.aff74ec and batarang #279

Closed SanderElias closed 8 years ago

SanderElias commented 8 years ago

If you use the .component helper form this build, and you have batarang active, the following error will be thrown.

script.js:8 Uncaught TypeError: angular.module(...).component is not a function

Took me some time to figure out what was happening... Disable batarang, and your component(s) start working!

Posted here also as sugessted in #13275

Narretz commented 8 years ago

@btford @SomeKittens Do you know what could be causing this? I assume batarang decorates the angular.Module functions / or provides its own implementation, and .component isn't yet part of that.

SomeKittens commented 8 years ago

@Narretz Yep, that'd be the first place to look. I've got some time, checking into this

SomeKittens commented 8 years ago

Here's the relevant code:

angular.module = function(name, requiresOriginal) {
  var module = originalAngularModule.apply(this, arguments),
      name = module.name;

  module.requiresOriginal = requiresOriginal;
  modules[name] = module;
  var modToCheck = getModule(name, true);
  //check arguments to determine if called as setter or getter
  var modIsSetter = arguments.length > 1;

  if (modIsSetter) {
    hasNameSpace(name);
  }

  if(modToCheck && modToCheck.requiresOriginal !== module.requiresOriginal && modIsSetter) {
    if(!modData.createdMulti[name]) {
      modData.createdMulti[name] = [getModule(name,true)];
    }
    modData.createdMulti[name].push(module);
  }
  modData.createdModules[name] = module;
  return module;
};

Since we're returning the result of a call to the original module function, I'm going to punt this back over the fence.

SanderElias commented 8 years ago

hmm. probably .component will get attached later, as it is an extension on .directive. It seems batarang gets in between there. I wonder how that could happen. One would think that those things are handed around per reference.

gkalpak commented 8 years ago

I still think the problem is within Batarang. It is somehow defining window.angular I think, so it is already defined when setupModuleLoader() is executed, thus our factory function is never called.

Will have to take a closer look to make sure, though.

gkalpak commented 8 years ago

Hm...yes, Batarang seems to have it's own loader (to retain compatibility with v1.2.x ?). So, it needs to get updated to include .component I guess.

I'm punting this ba...ehm...re-opening this for further investigation :smiley:

SomeKittens commented 8 years ago

Well, I never was very good at football anyway.

Yep, that's us, need to fix that loader. Completely forgot about it.

SomeKittens commented 8 years ago

y'know what? Double my bad - this is a dupe of #275