break-on-access

break on access to a property

  • 所有者: paulirish/break-on-access
  • 平台:
  • 許可證: Other
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

Usage

Omg the cookie is being changed, but where? Give me a breakpoint when JS changes my cookies!

breakOn(document, 'cookie');

Some JS is getting the scrollTop value causing massive Recalculate Styles costs. Who is the perpetrator PERFetrator?

breakOn(document.body,'scrollTop', 'read')

This works really well as a snippet in the Chrome DevTools:

By default, breakOn will only break when JS attempts to change the value of a property. The third optional argument takes 'read' if you'd also like to break when values are read.

It is also possible to disable/enable a breakpoint by using methods provided by returned object.

    var bp = breakOn(document, 'cookie');
    // found it!
    bp.disable();
    // something else is up....
    bp.enable();

breakOn also supports Conditional Breakpoints when the 4th argument is a function.
Say you know a property is being changed after the 4th change.

    var i = 0;
    var bp = breakOn(document, 'cookie', false, function(v) {
        return i++ >= 4;
    });

Or something is leaving a property undefined

    var bp = breakOn(document, 'cookie', false, function(v) {
        return typeof v === 'undefined';
    });

Authors

Dave Methvin, Paul Irish, fat, and these handsome people

Alternatives

History

Object.defineProperty(twttr, 'profile', {
    get: function () {
      debugger
    }
  , set: function (val) {
      debugger
    }
})

主要指標

概覽
名稱與所有者paulirish/break-on-access
主編程語言JavaScript
編程語言JavaScript (語言數: 2)
平台
許可證Other
所有者活动
創建於2013-09-15 20:07:06
推送於2019-06-02 23:18:13
最后一次提交2018-03-08 20:03:36
發布數0
用户参与
星數1.2k
關注者數37
派生數129
提交數33
已啟用問題?
問題數15
打開的問題數8
拉請求數5
打開的拉請求數2
關閉的拉請求數3
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?