blackboxed zone.js在开发人员工具中,但仍然进入zone.js

时间:2017-12-31 02:06:41

标签: javascript html angular angularjs-directive zone.js

  • 我是Angular的新手。
  • 我正在调试以下分数方法。
  • 当我跨越开发人员工具时,编码:true得分()进入zone.js。
  • 我blackboxed zone.js但仍然进入zone.js并指向此行task.callback.apply(applyThis,applyArgs);
  • 你能告诉我它为什么要去zone.js,尽管我已经黑盒子了。
  • 如果你们让我知道那将是很好的,以便将来我可以自己解决。
  • 在下面提供我的代码

我的代码

scores() {
    let that = this;
    this.redoCount = 0;
    this.undoCount = 0;
    this.datasourceList = [];
    this.createDatePicker();
    $("#optPlayerDetaileditor").kendoEditor({
        tools: ["bold", "italic", "underline"],
        change: function () {
            that.sportsPlayer.sportsPlayerDetailsText = this.value();
            let eventData = { "eventKey": "optPlayerDetaileditor", "sourceValue": that.sportsPlayerDetailSource, "destinationValue": that.sportsPlayer.sportsPlayerDetailsText, "type": "generateBtn" }
            that.eventCapture(eventData);
            that.sportsPlayerDetailSource = that.sportsPlayer.sportsPlayerDetailsText;
            that.saveBtnEnableDisable();
        }, encoded: true,
        serialization: {
            semantic: false,
            entities: false,
            custom: function (html) {
                return html.replace(/<b>/g, "<B>").replace(/<\/b>/g, "</B>").replace(/<i>/g, "<I>").replace(/<\/i>/g, "</I>").replace(/<u>/g, "<U>")
                    .replace(/<\/u>/g, "</U>").replace(/<br \/>/g, "\n").replace(/&nbsp;/g, " ").replace(/&amp;/g, "&").replace(/&quot;/g, '"').replace(/&gt;/g, ">")
                    .replace(/&lt;/g, "<").replace(/&middot;/g, ".").replace(/&nbsp;/g, " ");
            }
        },
    }).text();
}

zone.js

ZoneDelegate.prototype.invokeTask = function (targetZone, task, applyThis, applyArgs) {
    try {
        return this._invokeTaskZS
                    ? this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt, this.zone, targetZone, task, applyThis, applyArgs)
                    : task.callback.apply(applyThis, applyArgs);
}

1 个答案:

答案 0 :(得分:0)

不确定blackboxing Zone.js是什么意思但是调用方法task.callback.apply(applyThis, applyArgs)来调用任何计划任务。

E.g。如果执行window.setTimeout(cb,1000);,这实际上会调用monkey patched API而不是window.setTimeout。在该API中,新的Task对象为created,其属性callback已使用cb方法中传递的setTimeout进行初始化。此外,cb被另一个称为timer函数的回调替换。现在,当时间到期时,JS VM将调用Zone.js的回调方法,即timer,最终将调用task.callback.apply(applyThis, applyArgs)

有关Zone.js Monkey补丁API的详细信息,请参阅以下文章。

https://medium.com/reverse-engineering-angular/angular-deep-dive-zone-js-how-does-it-monkey-patches-various-apis-9cc1c7fcc321