javascript - debugInfoEnabled for Angular 1.2 - Stack Overflow

Angular 1.3 introduced a new debugInfoEnabled() method that can provide a boost in performance if calle

Angular 1.3 introduced a new debugInfoEnabled() method that can provide a boost in performance if called with false in the application config function:

myApp.config(['$pileProvider', function ($pileProvider) {
    $pileProvider.debugInfoEnabled(false);
}]);

Also, Angular 1.3 dropped IE8 support. And this is a problem for me, my application have to run on IE8. Hence, I cannot upgrade to angular 1.3 and have to live with 1.2.

Is there a way to achieve the same functionality with angular 1.2?

In particular, at least a part of what debugInfoEnabled() does:

  • prevent creation of ng-scope/ng-isolated-scope CSS classes while creating new scopes
  • do not attach binding data and ng-class CSS class to elements with ngBind, ngBindHtml or {{...}} interpolations

As one possible option, I can fork the angularjs repository and backport the feature back to 1.2. Then, use the fork maintaining updates from the upstream.

Would appreciate any pointers.

Angular 1.3 introduced a new debugInfoEnabled() method that can provide a boost in performance if called with false in the application config function:

myApp.config(['$pileProvider', function ($pileProvider) {
    $pileProvider.debugInfoEnabled(false);
}]);

Also, Angular 1.3 dropped IE8 support. And this is a problem for me, my application have to run on IE8. Hence, I cannot upgrade to angular 1.3 and have to live with 1.2.

Is there a way to achieve the same functionality with angular 1.2?

In particular, at least a part of what debugInfoEnabled() does:

  • prevent creation of ng-scope/ng-isolated-scope CSS classes while creating new scopes
  • do not attach binding data and ng-class CSS class to elements with ngBind, ngBindHtml or {{...}} interpolations

As one possible option, I can fork the angularjs repository and backport the feature back to 1.2. Then, use the fork maintaining updates from the upstream.

Would appreciate any pointers.

Share Improve this question edited Aug 18, 2016 at 16:04 Paul Sweatte 24.6k7 gold badges131 silver badges268 bronze badges asked Jan 5, 2015 at 16:05 alecxealecxe 474k127 gold badges1.1k silver badges1.2k bronze badges 5
  • what is the exact version of angular you're using? is it 1.2.7 or less than it – Pankaj Parkar Commented Jan 14, 2015 at 20:13
  • @pankajparkar trying to stick with latest 1.2.*. Currently 1.2.28. Thanks. – alecxe Commented Jan 14, 2015 at 20:23
  • try app.config(function($logProvider){ $logProvider.debugEnabled(true); }); inside you app – Pankaj Parkar Commented Jan 14, 2015 at 20:27
  • 1 Here's a build of Angular 1.3 which will work with IE8 github./fergaldoyle/angular.js-ie8-builds – Fergal Commented Jan 20, 2015 at 18:51
  • @Fergal wow, appreciate that. Thank you! – alecxe Commented Jan 20, 2015 at 18:52
Add a ment  | 

2 Answers 2

Reset to default 5 +50

Use the underlying DOM setAttribute method to prevent the default behavior. I've edited the plunker in the other answer:

http://plnkr.co/edit/cMar0d9IbalFxDA6AU3e?p=preview

to do the following:

  • Clone the DOM setAttribute prototype method
  • Override it with a check for ng debug attributes
  • Return false for ng debug attributes
  • Return as normal otherwise

Use it as follows:

/* Clone the original */
HTMLElement.prototype.ngSetAttribute = HTMLElement.prototype.setAttribute;

/* Override the API */
HTMLElement.prototype.setAttribute = function(foo, bar) {
/* Define ng attributes */ 
var nglist = {"ng-binding": true, "ng-scope":true,"ng-class":true,"ng-isolated-scope":true};

console.log([foo,bar]);

/* Block ng attributes; otherwise call the clone */
if (nglist[foo]) 
  return false; 
else if (JSON.stringify(nglist).match(foo) )
  return false;
else
  return this.ngSetAttribute(foo, bar);
}

Replace HTMLElement with Element for IE8.

References

  • CSS classes used by angular

  • Prototypes, Constructor Functions, and Taxidermy

  • AngularJS IE8 Shim

  • AngularJS IE8 Builds

  • Document Object Model Prototypes

  • Document Object Model Prototypes, Part 2: Accessor (getter/setter) Support

  • What's New in Internet Explorer 9

You can try disable it by mentioning $logProvider.debugEnabled(true); inside your angular configuration. In order to get effect of debugEnabled setting, You need ensure that while doing log use $log provider.

Sample Code

var app = angular.module('myApp', []);

app.config(function($logProvider){
  $logProvider.debugEnabled(false);
});

app.controller('MainCtrl', function($scope, $log ) {
  $scope.name = 'Hello World!';
  $scope.testModel = {name: "test"};
  //console.log('This will show log even if debugging is disable');
  $log.debug('TEST Log');
});

Here is Fiddle

Hopefully this will help you.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742275174a4413450.html

相关推荐

  • javascript - debugInfoEnabled for Angular 1.2 - Stack Overflow

    Angular 1.3 introduced a new debugInfoEnabled() method that can provide a boost in performance if calle

    23小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信