Skip to content

Commit

Permalink
Fixes exception with unannotated directive declarations in older Angu…
Browse files Browse the repository at this point in the history
…lar versions
  • Loading branch information
rev087 committed Apr 15, 2015
1 parent 1033161 commit 9b35153
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 8 deletions.
14 changes: 12 additions & 2 deletions ng-inspector.chrome/ng-inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -732,8 +732,18 @@ NGI.Service = (function() {

switch(this.provider) {
case '$compileProvider':
if (!this.factory.$inject) {
this.factory.$inject = app.$injector.annotate(this.factory);

// Unnannotated directives declared in the application will throw an exception.
// If $injector.annotate is available in the user's version of Angular we
// attempt to salvage it, otherwise return and ignore the directive.
if (Object.prototype.toString.call(this.factory) !== '[object Array]') {
if (app.$injector.annotate) {
var annotated = app.$injector.annotate(this.factory);
annotated.push(this.factory);
this.factory = annotated;
} else {
return;
}
}
var dir = app.$injector.invoke(this.factory);
if (!dir) {
Expand Down
14 changes: 12 additions & 2 deletions ng-inspector.safariextension/ng-inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -732,8 +732,18 @@ NGI.Service = (function() {

switch(this.provider) {
case '$compileProvider':
if (!this.factory.$inject) {
this.factory.$inject = app.$injector.annotate(this.factory);

// Unnannotated directives declared in the application will throw an exception.
// If $injector.annotate is available in the user's version of Angular we
// attempt to salvage it, otherwise return and ignore the directive.
if (Object.prototype.toString.call(this.factory) !== '[object Array]') {
if (app.$injector.annotate) {
var annotated = app.$injector.annotate(this.factory);
annotated.push(this.factory);
this.factory = annotated;
} else {
return;
}
}
var dir = app.$injector.invoke(this.factory);
if (!dir) {
Expand Down
14 changes: 12 additions & 2 deletions src/js/Service.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,18 @@ NGI.Service = (function() {

switch(this.provider) {
case '$compileProvider':
if (!this.factory.$inject) {
this.factory.$inject = app.$injector.annotate(this.factory);

// Unnannotated directives declared in the application will throw an exception.
// If $injector.annotate is available in the user's version of Angular we
// attempt to salvage it, otherwise return and ignore the directive.
if (Object.prototype.toString.call(this.factory) !== '[object Array]') {
if (app.$injector.annotate) {
var annotated = app.$injector.annotate(this.factory);
annotated.push(this.factory);
this.factory = annotated;
} else {
return;
}
}
var dir = app.$injector.invoke(this.factory);
if (!dir) {
Expand Down
14 changes: 12 additions & 2 deletions test/e2e/scenarios/lib/ng-inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -732,8 +732,18 @@ NGI.Service = (function() {

switch(this.provider) {
case '$compileProvider':
if (!this.factory.$inject) {
this.factory.$inject = app.$injector.annotate(this.factory);

// Unnannotated directives declared in the application will throw an exception.
// If $injector.annotate is available in the user's version of Angular we
// attempt to salvage it, otherwise return and ignore the directive.
if (Object.prototype.toString.call(this.factory) !== '[object Array]') {
if (app.$injector.annotate) {
var annotated = app.$injector.annotate(this.factory);
annotated.push(this.factory);
this.factory = annotated;
} else {
return;
}
}
var dir = app.$injector.invoke(this.factory);
if (!dir) {
Expand Down

0 comments on commit 9b35153

Please sign in to comment.