зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1522404
- Refactor devtools/server/actors/inspector/event-parsers.js to use ES6 classes r=ochameau
Differential Revision: https://phabricator.services.mozilla.com/D17651 --HG-- rename : devtools/server/actors/inspector/event-parsers.js => devtools/server/actors/inspector/event-collector.js extra : moz-landing-system : lando
This commit is contained in:
Родитель
596e337c2d
Коммит
54775deef8
|
@ -24,47 +24,24 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "function() {\n" +
|
||||
" // Make sure that the DOM is not already loaded\n" +
|
||||
" if (!jQuery.isReady) {\n" +
|
||||
" // Remember that the DOM is ready\n" +
|
||||
" jQuery.isReady = true;\n" +
|
||||
"\n" +
|
||||
" // If there are functions bound, to execute\n" +
|
||||
" if (jQuery.readyList) {\n" +
|
||||
" // Execute all of them\n" +
|
||||
" for (var i = 0; i < jQuery.readyList.length; i++)\n" +
|
||||
" jQuery.readyList[i].apply(document);\n" +
|
||||
"\n" +
|
||||
" // Reset the list of functions\n" +
|
||||
" jQuery.readyList = null;\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
"}"
|
||||
},
|
||||
{
|
||||
type: "load",
|
||||
filename: URL_ROOT + TEST_LIB + ":1117",
|
||||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function() {\n" +
|
||||
" // Make sure that the DOM is not already loaded\n" +
|
||||
" if (!jQuery.isReady) {\n" +
|
||||
" // Remember that the DOM is ready\n" +
|
||||
" jQuery.isReady = true;\n" +
|
||||
"\n" +
|
||||
" // If there are functions bound, to execute\n" +
|
||||
" if (jQuery.readyList) {\n" +
|
||||
" // Execute all of them\n" +
|
||||
" for (var i = 0; i < jQuery.readyList.length; i++)\n" +
|
||||
" jQuery.readyList[i].apply(document);\n" +
|
||||
"\n" +
|
||||
" // Reset the list of functions\n" +
|
||||
" jQuery.readyList = null;\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function() {
|
||||
// Make sure that the DOM is not already loaded
|
||||
if (!jQuery.isReady) {
|
||||
// Remember that the DOM is ready
|
||||
jQuery.isReady = true;
|
||||
|
||||
// If there are functions bound, to execute
|
||||
if (jQuery.readyList) {
|
||||
// Execute all of them
|
||||
for (var i = 0; i < jQuery.readyList.length; i++)
|
||||
jQuery.readyList[i].apply(document);
|
||||
|
||||
// Reset the list of functions
|
||||
jQuery.readyList = null;
|
||||
}
|
||||
}
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "load",
|
||||
|
@ -73,59 +50,60 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "() => {\n" +
|
||||
" var handler1 = function liveDivDblClick() {\n" +
|
||||
" alert(1);\n" +
|
||||
" };\n" +
|
||||
" var handler2 = function liveDivDragStart() {\n" +
|
||||
" alert(2);\n" +
|
||||
" };\n" +
|
||||
" var handler3 = function liveDivDragLeave() {\n" +
|
||||
" alert(3);\n" +
|
||||
" };\n" +
|
||||
" var handler4 = function liveDivDragEnd() {\n" +
|
||||
" alert(4);\n" +
|
||||
" };\n" +
|
||||
" var handler5 = function liveDivDrop() {\n" +
|
||||
" alert(5);\n" +
|
||||
" };\n" +
|
||||
" var handler6 = function liveDivDragOver() {\n" +
|
||||
" alert(6);\n" +
|
||||
" };\n" +
|
||||
" var handler7 = function divClick1() {\n" +
|
||||
" alert(7);\n" +
|
||||
" };\n" +
|
||||
" var handler8 = function divClick2() {\n" +
|
||||
" alert(8);\n" +
|
||||
" };\n" +
|
||||
" var handler9 = function divKeyDown() {\n" +
|
||||
" alert(9);\n" +
|
||||
" };\n" +
|
||||
" var handler10 = function divDragOut() {\n" +
|
||||
" alert(10);\n" +
|
||||
" };\n" +
|
||||
"\n" +
|
||||
" if ($(\"#livediv\").live) {\n" +
|
||||
" $(\"#livediv\").live(\"dblclick\", handler1);\n" +
|
||||
" $(\"#livediv\").live(\"dragstart\", handler2);\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" if ($(\"#livediv\").delegate) {\n" +
|
||||
" $(document).delegate(\"#livediv\", \"dragleave\", handler3);\n" +
|
||||
" $(document).delegate(\"#livediv\", \"dragend\", handler4);\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" if ($(\"#livediv\").on) {\n" +
|
||||
" $(document).on(\"drop\", \"#livediv\", handler5);\n" +
|
||||
" $(document).on(\"dragover\", \"#livediv\", handler6);\n" +
|
||||
" $(document).on(\"dragout\", \"#livediv:xxxxx\", handler10);\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" var div = $(\"div\")[0];\n" +
|
||||
" $(div).click(handler7);\n" +
|
||||
" $(div).click(handler8);\n" +
|
||||
" $(div).keydown(handler9);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
() => {
|
||||
var handler1 = function liveDivDblClick() {
|
||||
alert(1);
|
||||
};
|
||||
var handler2 = function liveDivDragStart() {
|
||||
alert(2);
|
||||
};
|
||||
var handler3 = function liveDivDragLeave() {
|
||||
alert(3);
|
||||
};
|
||||
var handler4 = function liveDivDragEnd() {
|
||||
alert(4);
|
||||
};
|
||||
var handler5 = function liveDivDrop() {
|
||||
alert(5);
|
||||
};
|
||||
var handler6 = function liveDivDragOver() {
|
||||
alert(6);
|
||||
};
|
||||
var handler7 = function divClick1() {
|
||||
alert(7);
|
||||
};
|
||||
var handler8 = function divClick2() {
|
||||
alert(8);
|
||||
};
|
||||
var handler9 = function divKeyDown() {
|
||||
alert(9);
|
||||
};
|
||||
var handler10 = function divDragOut() {
|
||||
alert(10);
|
||||
};
|
||||
|
||||
if ($("#livediv").live) {
|
||||
$("#livediv").live("dblclick", handler1);
|
||||
$("#livediv").live("dragstart", handler2);
|
||||
}
|
||||
|
||||
if ($("#livediv").delegate) {
|
||||
$(document).delegate("#livediv", "dragleave", handler3);
|
||||
$(document).delegate("#livediv", "dragend", handler4);
|
||||
}
|
||||
|
||||
if ($("#livediv").on) {
|
||||
$(document).on("drop", "#livediv", handler5);
|
||||
$(document).on("dragover", "#livediv", handler6);
|
||||
$(document).on("dragout", "#livediv:xxxxx", handler10);
|
||||
}
|
||||
|
||||
var div = $("div")[0];
|
||||
$(div).click(handler7);
|
||||
$(div).click(handler8);
|
||||
$(div).keydown(handler9);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "load",
|
||||
|
@ -134,28 +112,29 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "function(event) {\n" +
|
||||
" if (typeof jQuery == \"undefined\") return;\n" +
|
||||
"\n" +
|
||||
" event = event || jQuery.event.fix(window.event);\n" +
|
||||
"\n" +
|
||||
" // If no correct event was found, fail\n" +
|
||||
" if (!event) return;\n" +
|
||||
"\n" +
|
||||
" var returnValue = true;\n" +
|
||||
"\n" +
|
||||
" var c = this.events[event.type];\n" +
|
||||
"\n" +
|
||||
" for (var j in c) {\n" +
|
||||
" if (c[j].apply(this, [event]) === false) {\n" +
|
||||
" event.preventDefault();\n" +
|
||||
" event.stopPropagation();\n" +
|
||||
" returnValue = false;\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" return returnValue;\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function(event) {
|
||||
if (typeof jQuery == "undefined") return;
|
||||
|
||||
event = event || jQuery.event.fix(window.event);
|
||||
|
||||
// If no correct event was found, fail
|
||||
if (!event) return;
|
||||
|
||||
var returnValue = true;
|
||||
|
||||
var c = this.events[event.type];
|
||||
|
||||
for (var j in c) {
|
||||
if (c[j].apply(this, [event]) === false) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
returnValue = false;
|
||||
}
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -168,9 +147,10 @@ const TEST_DATA = [
|
|||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function divClick1() {\n" +
|
||||
" alert(7);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function divClick1() {
|
||||
alert(7);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "click",
|
||||
|
@ -178,9 +158,10 @@ const TEST_DATA = [
|
|||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function divClick2() {\n" +
|
||||
" alert(8);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function divClick2() {
|
||||
alert(8);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "click",
|
||||
|
@ -189,28 +170,29 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "function(event) {\n" +
|
||||
" if (typeof jQuery == \"undefined\") return;\n" +
|
||||
"\n" +
|
||||
" event = event || jQuery.event.fix(window.event);\n" +
|
||||
"\n" +
|
||||
" // If no correct event was found, fail\n" +
|
||||
" if (!event) return;\n" +
|
||||
"\n" +
|
||||
" var returnValue = true;\n" +
|
||||
"\n" +
|
||||
" var c = this.events[event.type];\n" +
|
||||
"\n" +
|
||||
" for (var j in c) {\n" +
|
||||
" if (c[j].apply(this, [event]) === false) {\n" +
|
||||
" event.preventDefault();\n" +
|
||||
" event.stopPropagation();\n" +
|
||||
" returnValue = false;\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" return returnValue;\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function(event) {
|
||||
if (typeof jQuery == "undefined") return;
|
||||
|
||||
event = event || jQuery.event.fix(window.event);
|
||||
|
||||
// If no correct event was found, fail
|
||||
if (!event) return;
|
||||
|
||||
var returnValue = true;
|
||||
|
||||
var c = this.events[event.type];
|
||||
|
||||
for (var j in c) {
|
||||
if (c[j].apply(this, [event]) === false) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
returnValue = false;
|
||||
}
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "keydown",
|
||||
|
@ -218,9 +200,10 @@ const TEST_DATA = [
|
|||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function divKeyDown() {\n" +
|
||||
" alert(9);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function divKeyDown() {
|
||||
alert(9);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "keydown",
|
||||
|
@ -229,28 +212,29 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "function(event) {\n" +
|
||||
" if (typeof jQuery == \"undefined\") return;\n" +
|
||||
"\n" +
|
||||
" event = event || jQuery.event.fix(window.event);\n" +
|
||||
"\n" +
|
||||
" // If no correct event was found, fail\n" +
|
||||
" if (!event) return;\n" +
|
||||
"\n" +
|
||||
" var returnValue = true;\n" +
|
||||
"\n" +
|
||||
" var c = this.events[event.type];\n" +
|
||||
"\n" +
|
||||
" for (var j in c) {\n" +
|
||||
" if (c[j].apply(this, [event]) === false) {\n" +
|
||||
" event.preventDefault();\n" +
|
||||
" event.stopPropagation();\n" +
|
||||
" returnValue = false;\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" return returnValue;\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function(event) {
|
||||
if (typeof jQuery == "undefined") return;
|
||||
|
||||
event = event || jQuery.event.fix(window.event);
|
||||
|
||||
// If no correct event was found, fail
|
||||
if (!event) return;
|
||||
|
||||
var returnValue = true;
|
||||
|
||||
var c = this.events[event.type];
|
||||
|
||||
for (var j in c) {
|
||||
if (c[j].apply(this, [event]) === false) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
returnValue = false;
|
||||
}
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -17,34 +17,6 @@ const TEST_DATA = [
|
|||
{
|
||||
selector: "html",
|
||||
expected: [
|
||||
{
|
||||
type: "load",
|
||||
filename: URL_ROOT + TEST_LIB + ":1387",
|
||||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function() {\n" +
|
||||
" // Make sure that the DOM is not already loaded\n" +
|
||||
" if (!jQuery.isReady) {\n" +
|
||||
" // Remember that the DOM is ready\n" +
|
||||
" jQuery.isReady = true;\n" +
|
||||
"\n" +
|
||||
" // If there are functions bound, to execute\n" +
|
||||
" if (jQuery.readyList) {\n" +
|
||||
" // Execute all of them\n" +
|
||||
" jQuery.each(jQuery.readyList, function() {\n" +
|
||||
" this.apply(document);\n" +
|
||||
" });\n" +
|
||||
"\n" +
|
||||
" // Reset the list of functions\n" +
|
||||
" jQuery.readyList = null;\n" +
|
||||
" }\n" +
|
||||
" // Remove event lisenter to avoid memory leak\n" +
|
||||
" if (jQuery.browser.mozilla || jQuery.browser.opera)\n" +
|
||||
" document.removeEventListener(\"DOMContentLoaded\", jQuery.ready, false);\n" +
|
||||
" }\n" +
|
||||
"}"
|
||||
},
|
||||
{
|
||||
type: "load",
|
||||
filename: TEST_URL + ":27",
|
||||
|
@ -52,59 +24,60 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "() => {\n" +
|
||||
" var handler1 = function liveDivDblClick() {\n" +
|
||||
" alert(1);\n" +
|
||||
" };\n" +
|
||||
" var handler2 = function liveDivDragStart() {\n" +
|
||||
" alert(2);\n" +
|
||||
" };\n" +
|
||||
" var handler3 = function liveDivDragLeave() {\n" +
|
||||
" alert(3);\n" +
|
||||
" };\n" +
|
||||
" var handler4 = function liveDivDragEnd() {\n" +
|
||||
" alert(4);\n" +
|
||||
" };\n" +
|
||||
" var handler5 = function liveDivDrop() {\n" +
|
||||
" alert(5);\n" +
|
||||
" };\n" +
|
||||
" var handler6 = function liveDivDragOver() {\n" +
|
||||
" alert(6);\n" +
|
||||
" };\n" +
|
||||
" var handler7 = function divClick1() {\n" +
|
||||
" alert(7);\n" +
|
||||
" };\n" +
|
||||
" var handler8 = function divClick2() {\n" +
|
||||
" alert(8);\n" +
|
||||
" };\n" +
|
||||
" var handler9 = function divKeyDown() {\n" +
|
||||
" alert(9);\n" +
|
||||
" };\n" +
|
||||
" var handler10 = function divDragOut() {\n" +
|
||||
" alert(10);\n" +
|
||||
" };\n" +
|
||||
"\n" +
|
||||
" if ($(\"#livediv\").live) {\n" +
|
||||
" $(\"#livediv\").live(\"dblclick\", handler1);\n" +
|
||||
" $(\"#livediv\").live(\"dragstart\", handler2);\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" if ($(\"#livediv\").delegate) {\n" +
|
||||
" $(document).delegate(\"#livediv\", \"dragleave\", handler3);\n" +
|
||||
" $(document).delegate(\"#livediv\", \"dragend\", handler4);\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" if ($(\"#livediv\").on) {\n" +
|
||||
" $(document).on(\"drop\", \"#livediv\", handler5);\n" +
|
||||
" $(document).on(\"dragover\", \"#livediv\", handler6);\n" +
|
||||
" $(document).on(\"dragout\", \"#livediv:xxxxx\", handler10);\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" var div = $(\"div\")[0];\n" +
|
||||
" $(div).click(handler7);\n" +
|
||||
" $(div).click(handler8);\n" +
|
||||
" $(div).keydown(handler9);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
() => {
|
||||
var handler1 = function liveDivDblClick() {
|
||||
alert(1);
|
||||
};
|
||||
var handler2 = function liveDivDragStart() {
|
||||
alert(2);
|
||||
};
|
||||
var handler3 = function liveDivDragLeave() {
|
||||
alert(3);
|
||||
};
|
||||
var handler4 = function liveDivDragEnd() {
|
||||
alert(4);
|
||||
};
|
||||
var handler5 = function liveDivDrop() {
|
||||
alert(5);
|
||||
};
|
||||
var handler6 = function liveDivDragOver() {
|
||||
alert(6);
|
||||
};
|
||||
var handler7 = function divClick1() {
|
||||
alert(7);
|
||||
};
|
||||
var handler8 = function divClick2() {
|
||||
alert(8);
|
||||
};
|
||||
var handler9 = function divKeyDown() {
|
||||
alert(9);
|
||||
};
|
||||
var handler10 = function divDragOut() {
|
||||
alert(10);
|
||||
};
|
||||
|
||||
if ($("#livediv").live) {
|
||||
$("#livediv").live("dblclick", handler1);
|
||||
$("#livediv").live("dragstart", handler2);
|
||||
}
|
||||
|
||||
if ($("#livediv").delegate) {
|
||||
$(document).delegate("#livediv", "dragleave", handler3);
|
||||
$(document).delegate("#livediv", "dragend", handler4);
|
||||
}
|
||||
|
||||
if ($("#livediv").on) {
|
||||
$(document).on("drop", "#livediv", handler5);
|
||||
$(document).on("dragover", "#livediv", handler6);
|
||||
$(document).on("dragout", "#livediv:xxxxx", handler10);
|
||||
}
|
||||
|
||||
var div = $("div")[0];
|
||||
$(div).click(handler7);
|
||||
$(div).click(handler8);
|
||||
$(div).keydown(handler9);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "load",
|
||||
|
@ -113,38 +86,39 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "function(event) {\n" +
|
||||
" if (typeof jQuery == \"undefined\") return false;\n" +
|
||||
"\n" +
|
||||
" // Empty object is for triggered events with no data\n" +
|
||||
" event = jQuery.event.fix(event || window.event || {});\n" +
|
||||
"\n" +
|
||||
" // returned undefined or false\n" +
|
||||
" var returnValue;\n" +
|
||||
"\n" +
|
||||
" var c = this.events[event.type];\n" +
|
||||
"\n" +
|
||||
" var args = [].slice.call(arguments, 1);\n" +
|
||||
" args.unshift(event);\n" +
|
||||
"\n" +
|
||||
" for (var j in c) {\n" +
|
||||
" // Pass in a reference to the handler function itself\n" +
|
||||
" // So that we can later remove it\n" +
|
||||
" args[0].handler = c[j];\n" +
|
||||
" args[0].data = c[j].data;\n" +
|
||||
"\n" +
|
||||
" if (c[j].apply(this, args) === false) {\n" +
|
||||
" event.preventDefault();\n" +
|
||||
" event.stopPropagation();\n" +
|
||||
" returnValue = false;\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" // Clean up added properties in IE to prevent memory leak\n" +
|
||||
" if (jQuery.browser.msie) event.target = event.preventDefault = event.stopPropagation = event.handler = event.data = null;\n" +
|
||||
"\n" +
|
||||
" return returnValue;\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function(event) {
|
||||
if (typeof jQuery == "undefined") return false;
|
||||
|
||||
// Empty object is for triggered events with no data
|
||||
event = jQuery.event.fix(event || window.event || {});
|
||||
|
||||
// returned undefined or false
|
||||
var returnValue;
|
||||
|
||||
var c = this.events[event.type];
|
||||
|
||||
var args = [].slice.call(arguments, 1);
|
||||
args.unshift(event);
|
||||
|
||||
for (var j in c) {
|
||||
// Pass in a reference to the handler function itself
|
||||
// So that we can later remove it
|
||||
args[0].handler = c[j];
|
||||
args[0].data = c[j].data;
|
||||
|
||||
if (c[j].apply(this, args) === false) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
returnValue = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Clean up added properties in IE to prevent memory leak
|
||||
if (jQuery.browser.msie) event.target = event.preventDefault = event.stopPropagation = event.handler = event.data = null;
|
||||
|
||||
return returnValue;
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -157,9 +131,10 @@ const TEST_DATA = [
|
|||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function divClick1() {\n" +
|
||||
" alert(7);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function divClick1() {
|
||||
alert(7);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "click",
|
||||
|
@ -167,9 +142,10 @@ const TEST_DATA = [
|
|||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function divClick2() {\n" +
|
||||
" alert(8);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function divClick2() {
|
||||
alert(8);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "click",
|
||||
|
@ -178,38 +154,39 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "function(event) {\n" +
|
||||
" if (typeof jQuery == \"undefined\") return false;\n" +
|
||||
"\n" +
|
||||
" // Empty object is for triggered events with no data\n" +
|
||||
" event = jQuery.event.fix(event || window.event || {});\n" +
|
||||
"\n" +
|
||||
" // returned undefined or false\n" +
|
||||
" var returnValue;\n" +
|
||||
"\n" +
|
||||
" var c = this.events[event.type];\n" +
|
||||
"\n" +
|
||||
" var args = [].slice.call(arguments, 1);\n" +
|
||||
" args.unshift(event);\n" +
|
||||
"\n" +
|
||||
" for (var j in c) {\n" +
|
||||
" // Pass in a reference to the handler function itself\n" +
|
||||
" // So that we can later remove it\n" +
|
||||
" args[0].handler = c[j];\n" +
|
||||
" args[0].data = c[j].data;\n" +
|
||||
"\n" +
|
||||
" if (c[j].apply(this, args) === false) {\n" +
|
||||
" event.preventDefault();\n" +
|
||||
" event.stopPropagation();\n" +
|
||||
" returnValue = false;\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" // Clean up added properties in IE to prevent memory leak\n" +
|
||||
" if (jQuery.browser.msie) event.target = event.preventDefault = event.stopPropagation = event.handler = event.data = null;\n" +
|
||||
"\n" +
|
||||
" return returnValue;\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function(event) {
|
||||
if (typeof jQuery == "undefined") return false;
|
||||
|
||||
// Empty object is for triggered events with no data
|
||||
event = jQuery.event.fix(event || window.event || {});
|
||||
|
||||
// returned undefined or false
|
||||
var returnValue;
|
||||
|
||||
var c = this.events[event.type];
|
||||
|
||||
var args = [].slice.call(arguments, 1);
|
||||
args.unshift(event);
|
||||
|
||||
for (var j in c) {
|
||||
// Pass in a reference to the handler function itself
|
||||
// So that we can later remove it
|
||||
args[0].handler = c[j];
|
||||
args[0].data = c[j].data;
|
||||
|
||||
if (c[j].apply(this, args) === false) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
returnValue = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Clean up added properties in IE to prevent memory leak
|
||||
if (jQuery.browser.msie) event.target = event.preventDefault = event.stopPropagation = event.handler = event.data = null;
|
||||
|
||||
return returnValue;
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "keydown",
|
||||
|
@ -217,9 +194,10 @@ const TEST_DATA = [
|
|||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function divKeyDown() {\n" +
|
||||
" alert(9);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function divKeyDown() {
|
||||
alert(9);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "keydown",
|
||||
|
@ -228,38 +206,39 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "function(event) {\n" +
|
||||
" if (typeof jQuery == \"undefined\") return false;\n" +
|
||||
"\n" +
|
||||
" // Empty object is for triggered events with no data\n" +
|
||||
" event = jQuery.event.fix(event || window.event || {});\n" +
|
||||
"\n" +
|
||||
" // returned undefined or false\n" +
|
||||
" var returnValue;\n" +
|
||||
"\n" +
|
||||
" var c = this.events[event.type];\n" +
|
||||
"\n" +
|
||||
" var args = [].slice.call(arguments, 1);\n" +
|
||||
" args.unshift(event);\n" +
|
||||
"\n" +
|
||||
" for (var j in c) {\n" +
|
||||
" // Pass in a reference to the handler function itself\n" +
|
||||
" // So that we can later remove it\n" +
|
||||
" args[0].handler = c[j];\n" +
|
||||
" args[0].data = c[j].data;\n" +
|
||||
"\n" +
|
||||
" if (c[j].apply(this, args) === false) {\n" +
|
||||
" event.preventDefault();\n" +
|
||||
" event.stopPropagation();\n" +
|
||||
" returnValue = false;\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" // Clean up added properties in IE to prevent memory leak\n" +
|
||||
" if (jQuery.browser.msie) event.target = event.preventDefault = event.stopPropagation = event.handler = event.data = null;\n" +
|
||||
"\n" +
|
||||
" return returnValue;\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function(event) {
|
||||
if (typeof jQuery == "undefined") return false;
|
||||
|
||||
// Empty object is for triggered events with no data
|
||||
event = jQuery.event.fix(event || window.event || {});
|
||||
|
||||
// returned undefined or false
|
||||
var returnValue;
|
||||
|
||||
var c = this.events[event.type];
|
||||
|
||||
var args = [].slice.call(arguments, 1);
|
||||
args.unshift(event);
|
||||
|
||||
for (var j in c) {
|
||||
// Pass in a reference to the handler function itself
|
||||
// So that we can later remove it
|
||||
args[0].handler = c[j];
|
||||
args[0].data = c[j].data;
|
||||
|
||||
if (c[j].apply(this, args) === false) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
returnValue = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Clean up added properties in IE to prevent memory leak
|
||||
if (jQuery.browser.msie) event.target = event.preventDefault = event.stopPropagation = event.handler = event.data = null;
|
||||
|
||||
return returnValue;
|
||||
}`
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -24,59 +24,60 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "() => {\n" +
|
||||
" var handler1 = function liveDivDblClick() {\n" +
|
||||
" alert(1);\n" +
|
||||
" };\n" +
|
||||
" var handler2 = function liveDivDragStart() {\n" +
|
||||
" alert(2);\n" +
|
||||
" };\n" +
|
||||
" var handler3 = function liveDivDragLeave() {\n" +
|
||||
" alert(3);\n" +
|
||||
" };\n" +
|
||||
" var handler4 = function liveDivDragEnd() {\n" +
|
||||
" alert(4);\n" +
|
||||
" };\n" +
|
||||
" var handler5 = function liveDivDrop() {\n" +
|
||||
" alert(5);\n" +
|
||||
" };\n" +
|
||||
" var handler6 = function liveDivDragOver() {\n" +
|
||||
" alert(6);\n" +
|
||||
" };\n" +
|
||||
" var handler7 = function divClick1() {\n" +
|
||||
" alert(7);\n" +
|
||||
" };\n" +
|
||||
" var handler8 = function divClick2() {\n" +
|
||||
" alert(8);\n" +
|
||||
" };\n" +
|
||||
" var handler9 = function divKeyDown() {\n" +
|
||||
" alert(9);\n" +
|
||||
" };\n" +
|
||||
" var handler10 = function divDragOut() {\n" +
|
||||
" alert(10);\n" +
|
||||
" };\n" +
|
||||
"\n" +
|
||||
" if ($(\"#livediv\").live) {\n" +
|
||||
" $(\"#livediv\").live(\"dblclick\", handler1);\n" +
|
||||
" $(\"#livediv\").live(\"dragstart\", handler2);\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" if ($(\"#livediv\").delegate) {\n" +
|
||||
" $(document).delegate(\"#livediv\", \"dragleave\", handler3);\n" +
|
||||
" $(document).delegate(\"#livediv\", \"dragend\", handler4);\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" if ($(\"#livediv\").on) {\n" +
|
||||
" $(document).on(\"drop\", \"#livediv\", handler5);\n" +
|
||||
" $(document).on(\"dragover\", \"#livediv\", handler6);\n" +
|
||||
" $(document).on(\"dragout\", \"#livediv:xxxxx\", handler10);\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" var div = $(\"div\")[0];\n" +
|
||||
" $(div).click(handler7);\n" +
|
||||
" $(div).click(handler8);\n" +
|
||||
" $(div).keydown(handler9);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
() => {
|
||||
var handler1 = function liveDivDblClick() {
|
||||
alert(1);
|
||||
};
|
||||
var handler2 = function liveDivDragStart() {
|
||||
alert(2);
|
||||
};
|
||||
var handler3 = function liveDivDragLeave() {
|
||||
alert(3);
|
||||
};
|
||||
var handler4 = function liveDivDragEnd() {
|
||||
alert(4);
|
||||
};
|
||||
var handler5 = function liveDivDrop() {
|
||||
alert(5);
|
||||
};
|
||||
var handler6 = function liveDivDragOver() {
|
||||
alert(6);
|
||||
};
|
||||
var handler7 = function divClick1() {
|
||||
alert(7);
|
||||
};
|
||||
var handler8 = function divClick2() {
|
||||
alert(8);
|
||||
};
|
||||
var handler9 = function divKeyDown() {
|
||||
alert(9);
|
||||
};
|
||||
var handler10 = function divDragOut() {
|
||||
alert(10);
|
||||
};
|
||||
|
||||
if ($("#livediv").live) {
|
||||
$("#livediv").live("dblclick", handler1);
|
||||
$("#livediv").live("dragstart", handler2);
|
||||
}
|
||||
|
||||
if ($("#livediv").delegate) {
|
||||
$(document).delegate("#livediv", "dragleave", handler3);
|
||||
$(document).delegate("#livediv", "dragend", handler4);
|
||||
}
|
||||
|
||||
if ($("#livediv").on) {
|
||||
$(document).on("drop", "#livediv", handler5);
|
||||
$(document).on("dragover", "#livediv", handler6);
|
||||
$(document).on("dragout", "#livediv:xxxxx", handler10);
|
||||
}
|
||||
|
||||
var div = $("div")[0];
|
||||
$(div).click(handler7);
|
||||
$(div).click(handler8);
|
||||
$(div).keydown(handler9);
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -90,9 +91,10 @@ const TEST_DATA = [
|
|||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function divClick1() {\n" +
|
||||
" alert(7);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function divClick1() {
|
||||
alert(7);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "click",
|
||||
|
@ -100,9 +102,10 @@ const TEST_DATA = [
|
|||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function divClick2() {\n" +
|
||||
" alert(8);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function divClick2() {
|
||||
alert(8);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "keydown",
|
||||
|
@ -110,9 +113,10 @@ const TEST_DATA = [
|
|||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function divKeyDown() {\n" +
|
||||
" alert(9);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function divKeyDown() {
|
||||
alert(9);
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -127,9 +131,10 @@ const TEST_DATA = [
|
|||
"jQuery",
|
||||
"Live"
|
||||
],
|
||||
handler: "function liveDivDragEnd() {\n" +
|
||||
" alert(4);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function liveDivDragEnd() {
|
||||
alert(4);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "dragleave",
|
||||
|
@ -138,9 +143,10 @@ const TEST_DATA = [
|
|||
"jQuery",
|
||||
"Live"
|
||||
],
|
||||
handler: "function liveDivDragLeave() {\n" +
|
||||
" alert(3);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function liveDivDragLeave() {
|
||||
alert(3);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "dragover",
|
||||
|
@ -149,9 +155,10 @@ const TEST_DATA = [
|
|||
"jQuery",
|
||||
"Live"
|
||||
],
|
||||
handler: "function liveDivDragOver() {\n" +
|
||||
" alert(6);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function liveDivDragOver() {
|
||||
alert(6);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "drop",
|
||||
|
@ -160,9 +167,10 @@ const TEST_DATA = [
|
|||
"jQuery",
|
||||
"Live"
|
||||
],
|
||||
handler: "function liveDivDrop() {\n" +
|
||||
" alert(5);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function liveDivDrop() {
|
||||
alert(5);
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -24,100 +24,61 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "() => {\n" +
|
||||
" var handler1 = function liveDivDblClick() {\n" +
|
||||
" alert(1);\n" +
|
||||
" };\n" +
|
||||
" var handler2 = function liveDivDragStart() {\n" +
|
||||
" alert(2);\n" +
|
||||
" };\n" +
|
||||
" var handler3 = function liveDivDragLeave() {\n" +
|
||||
" alert(3);\n" +
|
||||
" };\n" +
|
||||
" var handler4 = function liveDivDragEnd() {\n" +
|
||||
" alert(4);\n" +
|
||||
" };\n" +
|
||||
" var handler5 = function liveDivDrop() {\n" +
|
||||
" alert(5);\n" +
|
||||
" };\n" +
|
||||
" var handler6 = function liveDivDragOver() {\n" +
|
||||
" alert(6);\n" +
|
||||
" };\n" +
|
||||
" var handler7 = function divClick1() {\n" +
|
||||
" alert(7);\n" +
|
||||
" };\n" +
|
||||
" var handler8 = function divClick2() {\n" +
|
||||
" alert(8);\n" +
|
||||
" };\n" +
|
||||
" var handler9 = function divKeyDown() {\n" +
|
||||
" alert(9);\n" +
|
||||
" };\n" +
|
||||
" var handler10 = function divDragOut() {\n" +
|
||||
" alert(10);\n" +
|
||||
" };\n" +
|
||||
"\n" +
|
||||
" if ($(\"#livediv\").live) {\n" +
|
||||
" $(\"#livediv\").live(\"dblclick\", handler1);\n" +
|
||||
" $(\"#livediv\").live(\"dragstart\", handler2);\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" if ($(\"#livediv\").delegate) {\n" +
|
||||
" $(document).delegate(\"#livediv\", \"dragleave\", handler3);\n" +
|
||||
" $(document).delegate(\"#livediv\", \"dragend\", handler4);\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" if ($(\"#livediv\").on) {\n" +
|
||||
" $(document).on(\"drop\", \"#livediv\", handler5);\n" +
|
||||
" $(document).on(\"dragover\", \"#livediv\", handler6);\n" +
|
||||
" $(document).on(\"dragout\", \"#livediv:xxxxx\", handler10);\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" var div = $(\"div\")[0];\n" +
|
||||
" $(div).click(handler7);\n" +
|
||||
" $(div).click(handler8);\n" +
|
||||
" $(div).keydown(handler9);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
() => {
|
||||
var handler1 = function liveDivDblClick() {
|
||||
alert(1);
|
||||
};
|
||||
var handler2 = function liveDivDragStart() {
|
||||
alert(2);
|
||||
};
|
||||
var handler3 = function liveDivDragLeave() {
|
||||
alert(3);
|
||||
};
|
||||
var handler4 = function liveDivDragEnd() {
|
||||
alert(4);
|
||||
};
|
||||
var handler5 = function liveDivDrop() {
|
||||
alert(5);
|
||||
};
|
||||
var handler6 = function liveDivDragOver() {
|
||||
alert(6);
|
||||
};
|
||||
var handler7 = function divClick1() {
|
||||
alert(7);
|
||||
};
|
||||
var handler8 = function divClick2() {
|
||||
alert(8);
|
||||
};
|
||||
var handler9 = function divKeyDown() {
|
||||
alert(9);
|
||||
};
|
||||
var handler10 = function divDragOut() {
|
||||
alert(10);
|
||||
};
|
||||
|
||||
if ($("#livediv").live) {
|
||||
$("#livediv").live("dblclick", handler1);
|
||||
$("#livediv").live("dragstart", handler2);
|
||||
}
|
||||
|
||||
if ($("#livediv").delegate) {
|
||||
$(document).delegate("#livediv", "dragleave", handler3);
|
||||
$(document).delegate("#livediv", "dragend", handler4);
|
||||
}
|
||||
|
||||
if ($("#livediv").on) {
|
||||
$(document).on("drop", "#livediv", handler5);
|
||||
$(document).on("dragover", "#livediv", handler6);
|
||||
$(document).on("dragout", "#livediv:xxxxx", handler10);
|
||||
}
|
||||
|
||||
var div = $("div")[0];
|
||||
$(div).click(handler7);
|
||||
$(div).click(handler8);
|
||||
$(div).keydown(handler9);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "load",
|
||||
filename: URL_ROOT + TEST_LIB,
|
||||
attributes: [
|
||||
"Bubbling",
|
||||
"DOM0"
|
||||
],
|
||||
handler: "function(event) {\n" +
|
||||
" if (typeof jQuery == \"undefined\") return false;\n" +
|
||||
"\n" +
|
||||
" // Empty object is for triggered events with no data\n" +
|
||||
" event = jQuery.event.fix(event || window.event || {});\n" +
|
||||
"\n" +
|
||||
" // returned undefined or false\n" +
|
||||
" var returnValue;\n" +
|
||||
"\n" +
|
||||
" var c = this.events[event.type];\n" +
|
||||
"\n" +
|
||||
" var args = [].slice.call(arguments, 1);\n" +
|
||||
" args.unshift(event);\n" +
|
||||
"\n" +
|
||||
" for (var j in c) {\n" +
|
||||
" // Pass in a reference to the handler function itself\n" +
|
||||
" // So that we can later remove it\n" +
|
||||
" args[0].handler = c[j];\n" +
|
||||
" args[0].data = c[j].data;\n" +
|
||||
"\n" +
|
||||
" if (c[j].apply(this, args) === false) {\n" +
|
||||
" event.preventDefault();\n" +
|
||||
" event.stopPropagation();\n" +
|
||||
" returnValue = false;\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" // Clean up added properties in IE to prevent memory leak\n" +
|
||||
" if (jQuery.browser.msie) event.target = event.preventDefault = event.stopPropagation = event.handler = event.data = null;\n" +
|
||||
"\n" +
|
||||
" return returnValue;\n" +
|
||||
"}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -129,9 +90,10 @@ const TEST_DATA = [
|
|||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function divClick1() {\n" +
|
||||
" alert(7);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function divClick1() {
|
||||
alert(7);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "click",
|
||||
|
@ -139,9 +101,10 @@ const TEST_DATA = [
|
|||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function divClick2() {\n" +
|
||||
" alert(8);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function divClick2() {
|
||||
alert(8);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "click",
|
||||
|
@ -150,12 +113,13 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "function() {\n" +
|
||||
" var val;\n" +
|
||||
" if (typeof jQuery == \"undefined\" || jQuery.event.triggered) return val;\n" +
|
||||
" val = jQuery.event.handle.apply(element, arguments);\n" +
|
||||
" return val;\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function() {
|
||||
var val;
|
||||
if (typeof jQuery == "undefined" || jQuery.event.triggered) return val;
|
||||
val = jQuery.event.handle.apply(element, arguments);
|
||||
return val;
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "keydown",
|
||||
|
@ -163,9 +127,10 @@ const TEST_DATA = [
|
|||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function divKeyDown() {\n" +
|
||||
" alert(9);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function divKeyDown() {
|
||||
alert(9);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "keydown",
|
||||
|
@ -174,12 +139,13 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "function() {\n" +
|
||||
" var val;\n" +
|
||||
" if (typeof jQuery == \"undefined\" || jQuery.event.triggered) return val;\n" +
|
||||
" val = jQuery.event.handle.apply(element, arguments);\n" +
|
||||
" return val;\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function() {
|
||||
var val;
|
||||
if (typeof jQuery == "undefined" || jQuery.event.triggered) return val;
|
||||
val = jQuery.event.handle.apply(element, arguments);
|
||||
return val;
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -17,35 +17,6 @@ const TEST_DATA = [
|
|||
{
|
||||
selector: "html",
|
||||
expected: [
|
||||
{
|
||||
type: "dblclick",
|
||||
filename: URL_ROOT + TEST_LIB + ":19",
|
||||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function c(G) {\n" +
|
||||
" var D = RegExp(\"(^|\\\\.)\" + G.type + \"(\\\\.|$)\"),\n" +
|
||||
" F = true,\n" +
|
||||
" E = [];\n" +
|
||||
" n.each(n.data(this, \"events\").live || [], function(H, I) {\n" +
|
||||
" if (D.test(I.type)) {\n" +
|
||||
" var J = n(G.target).closest(I.data)[0];\n" +
|
||||
" if (J) {\n" +
|
||||
" E.push({\n" +
|
||||
" elem: J,\n" +
|
||||
" fn: I\n" +
|
||||
" })\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" });\n" +
|
||||
" n.each(E, function() {\n" +
|
||||
" if (!G.isImmediatePropagationStopped() && " + "this.fn.call(this.elem, G, this.fn.data) === false) {\n" +
|
||||
" F = false\n" +
|
||||
" }\n" +
|
||||
" });\n" +
|
||||
" return F\n" +
|
||||
"}"
|
||||
},
|
||||
{
|
||||
type: "DOMContentLoaded",
|
||||
filename: URL_ROOT + TEST_LIB + ":19",
|
||||
|
@ -53,78 +24,11 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "function() {\n" +
|
||||
" document.removeEventListener(\"DOMContentLoaded\", arguments.callee, false);\n" +
|
||||
" n.ready()\n" +
|
||||
"}"
|
||||
},
|
||||
{
|
||||
type: "dragstart",
|
||||
filename: URL_ROOT + TEST_LIB + ":19",
|
||||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function c(G) {\n" +
|
||||
" var D = RegExp(\"(^|\\\\.)\" + G.type + \"(\\\\.|$)\"),\n" +
|
||||
" F = true,\n" +
|
||||
" E = [];\n" +
|
||||
" n.each(n.data(this, \"events\").live || [], function(H, I) {\n" +
|
||||
" if (D.test(I.type)) {\n" +
|
||||
" var J = n(G.target).closest(I.data)[0];\n" +
|
||||
" if (J) {\n" +
|
||||
" E.push({\n" +
|
||||
" elem: J,\n" +
|
||||
" fn: I\n" +
|
||||
" })\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" });\n" +
|
||||
" n.each(E, function() {\n" +
|
||||
" if (!G.isImmediatePropagationStopped() && " + "this.fn.call(this.elem, G, this.fn.data) === false) {\n" +
|
||||
" F = false\n" +
|
||||
" }\n" +
|
||||
" });\n" +
|
||||
" return F\n" +
|
||||
"}"
|
||||
},
|
||||
{
|
||||
type: "live",
|
||||
filename: URL_ROOT + TEST_LIB + ":19",
|
||||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function() {\n" +
|
||||
" return E.apply(this, arguments)\n" +
|
||||
"}"
|
||||
},
|
||||
{
|
||||
type: "live",
|
||||
filename: URL_ROOT + TEST_LIB + ":19",
|
||||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function() {\n" +
|
||||
" return E.apply(this, arguments)\n" +
|
||||
"}"
|
||||
},
|
||||
{
|
||||
type: "load",
|
||||
filename: URL_ROOT + TEST_LIB + ":19",
|
||||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function() {\n" +
|
||||
" if (!n.isReady) {\n" +
|
||||
" n.isReady = true;\n" +
|
||||
" if (n.readyList) {\n" +
|
||||
" n.each(n.readyList, function() {\n" +
|
||||
" this.call(document, n)\n" +
|
||||
" });\n" +
|
||||
" n.readyList = null\n" +
|
||||
" }\n" +
|
||||
" n(document).triggerHandler(\"ready\")\n" +
|
||||
" }\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function() {
|
||||
document.removeEventListener("DOMContentLoaded", arguments.callee, false);
|
||||
n.ready()
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "load",
|
||||
|
@ -133,70 +37,60 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "() => {\n" +
|
||||
" var handler1 = function liveDivDblClick() {\n" +
|
||||
" alert(1);\n" +
|
||||
" };\n" +
|
||||
" var handler2 = function liveDivDragStart() {\n" +
|
||||
" alert(2);\n" +
|
||||
" };\n" +
|
||||
" var handler3 = function liveDivDragLeave() {\n" +
|
||||
" alert(3);\n" +
|
||||
" };\n" +
|
||||
" var handler4 = function liveDivDragEnd() {\n" +
|
||||
" alert(4);\n" +
|
||||
" };\n" +
|
||||
" var handler5 = function liveDivDrop() {\n" +
|
||||
" alert(5);\n" +
|
||||
" };\n" +
|
||||
" var handler6 = function liveDivDragOver() {\n" +
|
||||
" alert(6);\n" +
|
||||
" };\n" +
|
||||
" var handler7 = function divClick1() {\n" +
|
||||
" alert(7);\n" +
|
||||
" };\n" +
|
||||
" var handler8 = function divClick2() {\n" +
|
||||
" alert(8);\n" +
|
||||
" };\n" +
|
||||
" var handler9 = function divKeyDown() {\n" +
|
||||
" alert(9);\n" +
|
||||
" };\n" +
|
||||
" var handler10 = function divDragOut() {\n" +
|
||||
" alert(10);\n" +
|
||||
" };\n" +
|
||||
"\n" +
|
||||
" if ($(\"#livediv\").live) {\n" +
|
||||
" $(\"#livediv\").live(\"dblclick\", handler1);\n" +
|
||||
" $(\"#livediv\").live(\"dragstart\", handler2);\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" if ($(\"#livediv\").delegate) {\n" +
|
||||
" $(document).delegate(\"#livediv\", \"dragleave\", handler3);\n" +
|
||||
" $(document).delegate(\"#livediv\", \"dragend\", handler4);\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" if ($(\"#livediv\").on) {\n" +
|
||||
" $(document).on(\"drop\", \"#livediv\", handler5);\n" +
|
||||
" $(document).on(\"dragover\", \"#livediv\", handler6);\n" +
|
||||
" $(document).on(\"dragout\", \"#livediv:xxxxx\", handler10);\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" var div = $(\"div\")[0];\n" +
|
||||
" $(div).click(handler7);\n" +
|
||||
" $(div).click(handler8);\n" +
|
||||
" $(div).keydown(handler9);\n" +
|
||||
"}"
|
||||
},
|
||||
{
|
||||
type: "unload",
|
||||
filename: URL_ROOT + TEST_LIB + ":19",
|
||||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function(H) {\n" +
|
||||
" n(this).unbind(H, D);\n" +
|
||||
" return (E || G).apply(this, arguments)\n" +
|
||||
"}"
|
||||
handler: `
|
||||
() => {
|
||||
var handler1 = function liveDivDblClick() {
|
||||
alert(1);
|
||||
};
|
||||
var handler2 = function liveDivDragStart() {
|
||||
alert(2);
|
||||
};
|
||||
var handler3 = function liveDivDragLeave() {
|
||||
alert(3);
|
||||
};
|
||||
var handler4 = function liveDivDragEnd() {
|
||||
alert(4);
|
||||
};
|
||||
var handler5 = function liveDivDrop() {
|
||||
alert(5);
|
||||
};
|
||||
var handler6 = function liveDivDragOver() {
|
||||
alert(6);
|
||||
};
|
||||
var handler7 = function divClick1() {
|
||||
alert(7);
|
||||
};
|
||||
var handler8 = function divClick2() {
|
||||
alert(8);
|
||||
};
|
||||
var handler9 = function divKeyDown() {
|
||||
alert(9);
|
||||
};
|
||||
var handler10 = function divDragOut() {
|
||||
alert(10);
|
||||
};
|
||||
|
||||
if ($("#livediv").live) {
|
||||
$("#livediv").live("dblclick", handler1);
|
||||
$("#livediv").live("dragstart", handler2);
|
||||
}
|
||||
|
||||
if ($("#livediv").delegate) {
|
||||
$(document).delegate("#livediv", "dragleave", handler3);
|
||||
$(document).delegate("#livediv", "dragend", handler4);
|
||||
}
|
||||
|
||||
if ($("#livediv").on) {
|
||||
$(document).on("drop", "#livediv", handler5);
|
||||
$(document).on("dragover", "#livediv", handler6);
|
||||
$(document).on("dragout", "#livediv:xxxxx", handler10);
|
||||
}
|
||||
|
||||
var div = $("div")[0];
|
||||
$(div).click(handler7);
|
||||
$(div).click(handler8);
|
||||
$(div).keydown(handler9);
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -209,9 +103,10 @@ const TEST_DATA = [
|
|||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function divClick1() {\n" +
|
||||
" alert(7);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function divClick1() {
|
||||
alert(7);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "click",
|
||||
|
@ -219,9 +114,10 @@ const TEST_DATA = [
|
|||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function divClick2() {\n" +
|
||||
" alert(8);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function divClick2() {
|
||||
alert(8);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "keydown",
|
||||
|
@ -229,9 +125,10 @@ const TEST_DATA = [
|
|||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function divKeyDown() {\n" +
|
||||
" alert(9);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function divKeyDown() {
|
||||
alert(9);
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -245,9 +142,10 @@ const TEST_DATA = [
|
|||
"jQuery",
|
||||
"Live"
|
||||
],
|
||||
handler: "function() {\n" +
|
||||
" return E.apply(this, arguments)\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function() {
|
||||
return E.apply(this, arguments)
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "dragstart",
|
||||
|
@ -256,9 +154,10 @@ const TEST_DATA = [
|
|||
"jQuery",
|
||||
"Live"
|
||||
],
|
||||
handler: "function() {\n" +
|
||||
" return E.apply(this, arguments)\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function() {
|
||||
return E.apply(this, arguments)
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -17,16 +17,6 @@ const TEST_DATA = [
|
|||
{
|
||||
selector: "html",
|
||||
expected: [
|
||||
{
|
||||
type: "dblclick",
|
||||
filename: URL_ROOT + TEST_LIB + ":31",
|
||||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function() {\n" +
|
||||
" return a.apply(d || this, arguments)\n" +
|
||||
"}"
|
||||
},
|
||||
{
|
||||
type: "DOMContentLoaded",
|
||||
filename: URL_ROOT + TEST_LIB + ":32",
|
||||
|
@ -34,20 +24,11 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "function() {\n" +
|
||||
" s.removeEventListener(\"DOMContentLoaded\", M, false);\n" +
|
||||
" c.ready()\n" +
|
||||
"}"
|
||||
},
|
||||
{
|
||||
type: "dragstart",
|
||||
filename: URL_ROOT + TEST_LIB + ":31",
|
||||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function() {\n" +
|
||||
" return a.apply(d || this, arguments)\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function() {
|
||||
s.removeEventListener(\"DOMContentLoaded\", M, false);
|
||||
c.ready()
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "load",
|
||||
|
@ -56,59 +37,60 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "() => {\n" +
|
||||
" var handler1 = function liveDivDblClick() {\n" +
|
||||
" alert(1);\n" +
|
||||
" };\n" +
|
||||
" var handler2 = function liveDivDragStart() {\n" +
|
||||
" alert(2);\n" +
|
||||
" };\n" +
|
||||
" var handler3 = function liveDivDragLeave() {\n" +
|
||||
" alert(3);\n" +
|
||||
" };\n" +
|
||||
" var handler4 = function liveDivDragEnd() {\n" +
|
||||
" alert(4);\n" +
|
||||
" };\n" +
|
||||
" var handler5 = function liveDivDrop() {\n" +
|
||||
" alert(5);\n" +
|
||||
" };\n" +
|
||||
" var handler6 = function liveDivDragOver() {\n" +
|
||||
" alert(6);\n" +
|
||||
" };\n" +
|
||||
" var handler7 = function divClick1() {\n" +
|
||||
" alert(7);\n" +
|
||||
" };\n" +
|
||||
" var handler8 = function divClick2() {\n" +
|
||||
" alert(8);\n" +
|
||||
" };\n" +
|
||||
" var handler9 = function divKeyDown() {\n" +
|
||||
" alert(9);\n" +
|
||||
" };\n" +
|
||||
" var handler10 = function divDragOut() {\n" +
|
||||
" alert(10);\n" +
|
||||
" };\n" +
|
||||
"\n" +
|
||||
" if ($(\"#livediv\").live) {\n" +
|
||||
" $(\"#livediv\").live(\"dblclick\", handler1);\n" +
|
||||
" $(\"#livediv\").live(\"dragstart\", handler2);\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" if ($(\"#livediv\").delegate) {\n" +
|
||||
" $(document).delegate(\"#livediv\", \"dragleave\", handler3);\n" +
|
||||
" $(document).delegate(\"#livediv\", \"dragend\", handler4);\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" if ($(\"#livediv\").on) {\n" +
|
||||
" $(document).on(\"drop\", \"#livediv\", handler5);\n" +
|
||||
" $(document).on(\"dragover\", \"#livediv\", handler6);\n" +
|
||||
" $(document).on(\"dragout\", \"#livediv:xxxxx\", handler10);\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" var div = $(\"div\")[0];\n" +
|
||||
" $(div).click(handler7);\n" +
|
||||
" $(div).click(handler8);\n" +
|
||||
" $(div).keydown(handler9);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
() => {
|
||||
var handler1 = function liveDivDblClick() {
|
||||
alert(1);
|
||||
};
|
||||
var handler2 = function liveDivDragStart() {
|
||||
alert(2);
|
||||
};
|
||||
var handler3 = function liveDivDragLeave() {
|
||||
alert(3);
|
||||
};
|
||||
var handler4 = function liveDivDragEnd() {
|
||||
alert(4);
|
||||
};
|
||||
var handler5 = function liveDivDrop() {
|
||||
alert(5);
|
||||
};
|
||||
var handler6 = function liveDivDragOver() {
|
||||
alert(6);
|
||||
};
|
||||
var handler7 = function divClick1() {
|
||||
alert(7);
|
||||
};
|
||||
var handler8 = function divClick2() {
|
||||
alert(8);
|
||||
};
|
||||
var handler9 = function divKeyDown() {
|
||||
alert(9);
|
||||
};
|
||||
var handler10 = function divDragOut() {
|
||||
alert(10);
|
||||
};
|
||||
|
||||
if ($("#livediv").live) {
|
||||
$("#livediv").live("dblclick", handler1);
|
||||
$("#livediv").live("dragstart", handler2);
|
||||
}
|
||||
|
||||
if ($("#livediv").delegate) {
|
||||
$(document).delegate("#livediv", "dragleave", handler3);
|
||||
$(document).delegate("#livediv", "dragend", handler4);
|
||||
}
|
||||
|
||||
if ($("#livediv").on) {
|
||||
$(document).on("drop", "#livediv", handler5);
|
||||
$(document).on("dragover", "#livediv", handler6);
|
||||
$(document).on("dragout", "#livediv:xxxxx", handler10);
|
||||
}
|
||||
|
||||
var div = $("div")[0];
|
||||
$(div).click(handler7);
|
||||
$(div).click(handler8);
|
||||
$(div).keydown(handler9);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "load",
|
||||
|
@ -117,17 +99,18 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "function() {\n" +
|
||||
" if (!c.isReady) {\n" +
|
||||
" if (!s.body) return setTimeout(c.ready, 13);\n" +
|
||||
" c.isReady = true;\n" +
|
||||
" if (Q) {\n" +
|
||||
" for (var a, b = 0; a = Q[b++];) a.call(s, c);\n" +
|
||||
" Q = null\n" +
|
||||
" }\n" +
|
||||
" c.fn.triggerHandler && c(s).triggerHandler(\"ready\")\n" +
|
||||
" }\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function() {
|
||||
if (!c.isReady) {
|
||||
if (!s.body) return setTimeout(c.ready, 13);
|
||||
c.isReady = true;
|
||||
if (Q) {
|
||||
for (var a, b = 0; a = Q[b++];) a.call(s, c);
|
||||
Q = null
|
||||
}
|
||||
c.fn.triggerHandler && c(s).triggerHandler("ready")
|
||||
}
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -140,9 +123,10 @@ const TEST_DATA = [
|
|||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function divClick1() {\n" +
|
||||
" alert(7);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function divClick1() {
|
||||
alert(7);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "click",
|
||||
|
@ -150,9 +134,10 @@ const TEST_DATA = [
|
|||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function divClick2() {\n" +
|
||||
" alert(8);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function divClick2() {
|
||||
alert(8);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "keydown",
|
||||
|
@ -160,9 +145,10 @@ const TEST_DATA = [
|
|||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function divKeyDown() {\n" +
|
||||
" alert(9);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function divKeyDown() {
|
||||
alert(9);
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -176,9 +162,10 @@ const TEST_DATA = [
|
|||
"jQuery",
|
||||
"Live"
|
||||
],
|
||||
handler: "function() {\n" +
|
||||
" return a.apply(d || this, arguments)\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function() {
|
||||
return a.apply(d || this, arguments)
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "dblclick",
|
||||
|
@ -187,9 +174,10 @@ const TEST_DATA = [
|
|||
"jQuery",
|
||||
"Live"
|
||||
],
|
||||
handler: "function() {\n" +
|
||||
" return a.apply(d || this, arguments)\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function() {
|
||||
return a.apply(d || this, arguments)
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "dragstart",
|
||||
|
@ -198,9 +186,10 @@ const TEST_DATA = [
|
|||
"jQuery",
|
||||
"Live"
|
||||
],
|
||||
handler: "function() {\n" +
|
||||
" return a.apply(d || this, arguments)\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function() {
|
||||
return a.apply(d || this, arguments)
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "dragstart",
|
||||
|
@ -209,9 +198,10 @@ const TEST_DATA = [
|
|||
"jQuery",
|
||||
"Live"
|
||||
],
|
||||
handler: "function() {\n" +
|
||||
" return a.apply(d || this, arguments)\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function() {
|
||||
return a.apply(d || this, arguments)
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -26,9 +26,10 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "function() {\n" +
|
||||
" c.removeEventListener(\"DOMContentLoaded\", z, !1), e.ready()\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function() {
|
||||
c.removeEventListener("DOMContentLoaded", z, !1), e.ready()
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "load",
|
||||
|
@ -37,59 +38,60 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "() => {\n" +
|
||||
" var handler1 = function liveDivDblClick() {\n" +
|
||||
" alert(1);\n" +
|
||||
" };\n" +
|
||||
" var handler2 = function liveDivDragStart() {\n" +
|
||||
" alert(2);\n" +
|
||||
" };\n" +
|
||||
" var handler3 = function liveDivDragLeave() {\n" +
|
||||
" alert(3);\n" +
|
||||
" };\n" +
|
||||
" var handler4 = function liveDivDragEnd() {\n" +
|
||||
" alert(4);\n" +
|
||||
" };\n" +
|
||||
" var handler5 = function liveDivDrop() {\n" +
|
||||
" alert(5);\n" +
|
||||
" };\n" +
|
||||
" var handler6 = function liveDivDragOver() {\n" +
|
||||
" alert(6);\n" +
|
||||
" };\n" +
|
||||
" var handler7 = function divClick1() {\n" +
|
||||
" alert(7);\n" +
|
||||
" };\n" +
|
||||
" var handler8 = function divClick2() {\n" +
|
||||
" alert(8);\n" +
|
||||
" };\n" +
|
||||
" var handler9 = function divKeyDown() {\n" +
|
||||
" alert(9);\n" +
|
||||
" };\n" +
|
||||
" var handler10 = function divDragOut() {\n" +
|
||||
" alert(10);\n" +
|
||||
" };\n" +
|
||||
"\n" +
|
||||
" if ($(\"#livediv\").live) {\n" +
|
||||
" $(\"#livediv\").live(\"dblclick\", handler1);\n" +
|
||||
" $(\"#livediv\").live(\"dragstart\", handler2);\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" if ($(\"#livediv\").delegate) {\n" +
|
||||
" $(document).delegate(\"#livediv\", \"dragleave\", handler3);\n" +
|
||||
" $(document).delegate(\"#livediv\", \"dragend\", handler4);\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" if ($(\"#livediv\").on) {\n" +
|
||||
" $(document).on(\"drop\", \"#livediv\", handler5);\n" +
|
||||
" $(document).on(\"dragover\", \"#livediv\", handler6);\n" +
|
||||
" $(document).on(\"dragout\", \"#livediv:xxxxx\", handler10);\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" var div = $(\"div\")[0];\n" +
|
||||
" $(div).click(handler7);\n" +
|
||||
" $(div).click(handler8);\n" +
|
||||
" $(div).keydown(handler9);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
() => {
|
||||
var handler1 = function liveDivDblClick() {
|
||||
alert(1);
|
||||
};
|
||||
var handler2 = function liveDivDragStart() {
|
||||
alert(2);
|
||||
};
|
||||
var handler3 = function liveDivDragLeave() {
|
||||
alert(3);
|
||||
};
|
||||
var handler4 = function liveDivDragEnd() {
|
||||
alert(4);
|
||||
};
|
||||
var handler5 = function liveDivDrop() {
|
||||
alert(5);
|
||||
};
|
||||
var handler6 = function liveDivDragOver() {
|
||||
alert(6);
|
||||
};
|
||||
var handler7 = function divClick1() {
|
||||
alert(7);
|
||||
};
|
||||
var handler8 = function divClick2() {
|
||||
alert(8);
|
||||
};
|
||||
var handler9 = function divKeyDown() {
|
||||
alert(9);
|
||||
};
|
||||
var handler10 = function divDragOut() {
|
||||
alert(10);
|
||||
};
|
||||
|
||||
if ($("#livediv").live) {
|
||||
$("#livediv").live("dblclick", handler1);
|
||||
$("#livediv").live("dragstart", handler2);
|
||||
}
|
||||
|
||||
if ($("#livediv").delegate) {
|
||||
$(document).delegate("#livediv", "dragleave", handler3);
|
||||
$(document).delegate("#livediv", "dragend", handler4);
|
||||
}
|
||||
|
||||
if ($("#livediv").on) {
|
||||
$(document).on("drop", "#livediv", handler5);
|
||||
$(document).on("dragover", "#livediv", handler6);
|
||||
$(document).on("dragout", "#livediv:xxxxx", handler10);
|
||||
}
|
||||
|
||||
var div = $("div")[0];
|
||||
$(div).click(handler7);
|
||||
$(div).click(handler8);
|
||||
$(div).keydown(handler9);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "load",
|
||||
|
@ -98,14 +100,15 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "function(a) {\n" +
|
||||
" if (a === !0 && !--e.readyWait || a !== !0 && !e.isReady) {\n" +
|
||||
" if (!c.body) return setTimeout(e.ready, 1);\n" +
|
||||
" e.isReady = !0;\n" +
|
||||
" if (a !== !0 && --e.readyWait > 0) return;\n" +
|
||||
" y.resolveWith(c, [e]), e.fn.trigger && e(c).trigger(\"ready\").unbind(\"ready\")\n" +
|
||||
" }\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function(a) {
|
||||
if (a === !0 && !--e.readyWait || a !== !0 && !e.isReady) {
|
||||
if (!c.body) return setTimeout(e.ready, 1);
|
||||
e.isReady = !0;
|
||||
if (a !== !0 && --e.readyWait > 0) return;
|
||||
y.resolveWith(c, [e]), e.fn.trigger && e(c).trigger("ready").unbind("ready")
|
||||
}
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -118,9 +121,10 @@ const TEST_DATA = [
|
|||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function divClick1() {\n" +
|
||||
" alert(7);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function divClick1() {
|
||||
alert(7);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "click",
|
||||
|
@ -128,9 +132,10 @@ const TEST_DATA = [
|
|||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function divClick2() {\n" +
|
||||
" alert(8);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function divClick2() {
|
||||
alert(8);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "keydown",
|
||||
|
@ -138,9 +143,10 @@ const TEST_DATA = [
|
|||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function divKeyDown() {\n" +
|
||||
" alert(9);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function divKeyDown() {
|
||||
alert(9);
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -154,9 +160,10 @@ const TEST_DATA = [
|
|||
"jQuery",
|
||||
"Live"
|
||||
],
|
||||
handler: "function liveDivDblClick() {\n" +
|
||||
" alert(1);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function liveDivDblClick() {
|
||||
alert(1);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "dblclick",
|
||||
|
@ -165,42 +172,43 @@ const TEST_DATA = [
|
|||
"jQuery",
|
||||
"Live"
|
||||
],
|
||||
handler: "function M(a) {\n" +
|
||||
" var b, c, d, e, g, h, i, j, k, l, m, n, o, p = [],\n" +
|
||||
" q = [],\n" +
|
||||
" r = f._data(this, \"events\");\n" +
|
||||
" if (!(a.liveFired === this || !r || !r.live || a.target.disabled || a.button && a.type === \"click\")) {\n" +
|
||||
" a.namespace && (n = new RegExp(\"(^|\\\\.)\" + a.namespace.split(\".\").join(\"\\\\.(?:.*\\\\.)?\") + \"(\\\\.|$)\")), a.liveFired = this;\n" +
|
||||
" var s = r.live.slice(0);\n" +
|
||||
" for (i = 0; i < s.length; i++) g = s[i], g.origType.replace(x, \"\") === a.type ? q.push(g.selector) : s.splice(i--, 1);\n" +
|
||||
" e = f(a.target).closest(q, a.currentTarget);\n" +
|
||||
" for (j = 0, k = e.length; j < k; j++) {\n" +
|
||||
" m = e[j];\n" +
|
||||
" for (i = 0; i < s.length; i++) {\n" +
|
||||
" g = s[i];\n" +
|
||||
" if (m.selector === g.selector && (!n || n.test(g.namespace)) && !m.elem.disabled) {\n" +
|
||||
" h = m.elem, d = null;\n" +
|
||||
" if (g.preType === \"mouseenter\" || g.preType === \"mouseleave\") a.type = g.preType, d = f(a.relatedTarget).closest(g.selector)[0], d && f.contains(h, d) && (d = h);\n" +
|
||||
" (!d || d !== h) && p.push({\n" +
|
||||
" elem: h,\n" +
|
||||
" handleObj: g,\n" +
|
||||
" level: m.level\n" +
|
||||
" })\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" for (j = 0, k = p.length; j < k; j++) {\n" +
|
||||
" e = p[j];\n" +
|
||||
" if (c && e.level > c) break;\n" +
|
||||
" a.currentTarget = e.elem, a.data = e.handleObj.data, a.handleObj = e.handleObj, o = e.handleObj.origHandler.apply(e.elem, arguments);\n" +
|
||||
" if (o === !1 || a.isPropagationStopped()) {\n" +
|
||||
" c = e.level, o === !1 && (b = !1);\n" +
|
||||
" if (a.isImmediatePropagationStopped()) break\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" return b\n" +
|
||||
" }\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function M(a) {
|
||||
var b, c, d, e, g, h, i, j, k, l, m, n, o, p = [],
|
||||
q = [],
|
||||
r = f._data(this, "events");
|
||||
if (!(a.liveFired === this || !r || !r.live || a.target.disabled || a.button && a.type === "click")) {
|
||||
a.namespace && (n = new RegExp("(^|\\\\.)" + a.namespace.split(".").join("\\\\.(?:.*\\\\.)?") + "(\\\\.|$)")), a.liveFired = this;
|
||||
var s = r.live.slice(0);
|
||||
for (i = 0; i < s.length; i++) g = s[i], g.origType.replace(x, "") === a.type ? q.push(g.selector) : s.splice(i--, 1);
|
||||
e = f(a.target).closest(q, a.currentTarget);
|
||||
for (j = 0, k = e.length; j < k; j++) {
|
||||
m = e[j];
|
||||
for (i = 0; i < s.length; i++) {
|
||||
g = s[i];
|
||||
if (m.selector === g.selector && (!n || n.test(g.namespace)) && !m.elem.disabled) {
|
||||
h = m.elem, d = null;
|
||||
if (g.preType === "mouseenter" || g.preType === "mouseleave") a.type = g.preType, d = f(a.relatedTarget).closest(g.selector)[0], d && f.contains(h, d) && (d = h);
|
||||
(!d || d !== h) && p.push({
|
||||
elem: h,
|
||||
handleObj: g,
|
||||
level: m.level
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
for (j = 0, k = p.length; j < k; j++) {
|
||||
e = p[j];
|
||||
if (c && e.level > c) break;
|
||||
a.currentTarget = e.elem, a.data = e.handleObj.data, a.handleObj = e.handleObj, o = e.handleObj.origHandler.apply(e.elem, arguments);
|
||||
if (o === !1 || a.isPropagationStopped()) {
|
||||
c = e.level, o === !1 && (b = !1);
|
||||
if (a.isImmediatePropagationStopped()) break
|
||||
}
|
||||
}
|
||||
return b
|
||||
}
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "dragend",
|
||||
|
@ -209,9 +217,10 @@ const TEST_DATA = [
|
|||
"jQuery",
|
||||
"Live"
|
||||
],
|
||||
handler: "function liveDivDragEnd() {\n" +
|
||||
" alert(4);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function liveDivDragEnd() {
|
||||
alert(4);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "dragend",
|
||||
|
@ -220,42 +229,43 @@ const TEST_DATA = [
|
|||
"jQuery",
|
||||
"Live"
|
||||
],
|
||||
handler: "function M(a) {\n" +
|
||||
" var b, c, d, e, g, h, i, j, k, l, m, n, o, p = [],\n" +
|
||||
" q = [],\n" +
|
||||
" r = f._data(this, \"events\");\n" +
|
||||
" if (!(a.liveFired === this || !r || !r.live || a.target.disabled || a.button && a.type === \"click\")) {\n" +
|
||||
" a.namespace && (n = new RegExp(\"(^|\\\\.)\" + a.namespace.split(\".\").join(\"\\\\.(?:.*\\\\.)?\") + \"(\\\\.|$)\")), a.liveFired = this;\n" +
|
||||
" var s = r.live.slice(0);\n" +
|
||||
" for (i = 0; i < s.length; i++) g = s[i], g.origType.replace(x, \"\") === a.type ? q.push(g.selector) : s.splice(i--, 1);\n" +
|
||||
" e = f(a.target).closest(q, a.currentTarget);\n" +
|
||||
" for (j = 0, k = e.length; j < k; j++) {\n" +
|
||||
" m = e[j];\n" +
|
||||
" for (i = 0; i < s.length; i++) {\n" +
|
||||
" g = s[i];\n" +
|
||||
" if (m.selector === g.selector && (!n || n.test(g.namespace)) && !m.elem.disabled) {\n" +
|
||||
" h = m.elem, d = null;\n" +
|
||||
" if (g.preType === \"mouseenter\" || g.preType === \"mouseleave\") a.type = g.preType, d = f(a.relatedTarget).closest(g.selector)[0], d && f.contains(h, d) && (d = h);\n" +
|
||||
" (!d || d !== h) && p.push({\n" +
|
||||
" elem: h,\n" +
|
||||
" handleObj: g,\n" +
|
||||
" level: m.level\n" +
|
||||
" })\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" for (j = 0, k = p.length; j < k; j++) {\n" +
|
||||
" e = p[j];\n" +
|
||||
" if (c && e.level > c) break;\n" +
|
||||
" a.currentTarget = e.elem, a.data = e.handleObj.data, a.handleObj = e.handleObj, o = e.handleObj.origHandler.apply(e.elem, arguments);\n" +
|
||||
" if (o === !1 || a.isPropagationStopped()) {\n" +
|
||||
" c = e.level, o === !1 && (b = !1);\n" +
|
||||
" if (a.isImmediatePropagationStopped()) break\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" return b\n" +
|
||||
" }\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function M(a) {
|
||||
var b, c, d, e, g, h, i, j, k, l, m, n, o, p = [],
|
||||
q = [],
|
||||
r = f._data(this, "events");
|
||||
if (!(a.liveFired === this || !r || !r.live || a.target.disabled || a.button && a.type === "click")) {
|
||||
a.namespace && (n = new RegExp("(^|\\\\.)" + a.namespace.split(".").join("\\\\.(?:.*\\\\.)?") + "(\\\\.|$)")), a.liveFired = this;
|
||||
var s = r.live.slice(0);
|
||||
for (i = 0; i < s.length; i++) g = s[i], g.origType.replace(x, "") === a.type ? q.push(g.selector) : s.splice(i--, 1);
|
||||
e = f(a.target).closest(q, a.currentTarget);
|
||||
for (j = 0, k = e.length; j < k; j++) {
|
||||
m = e[j];
|
||||
for (i = 0; i < s.length; i++) {
|
||||
g = s[i];
|
||||
if (m.selector === g.selector && (!n || n.test(g.namespace)) && !m.elem.disabled) {
|
||||
h = m.elem, d = null;
|
||||
if (g.preType === "mouseenter" || g.preType === "mouseleave") a.type = g.preType, d = f(a.relatedTarget).closest(g.selector)[0], d && f.contains(h, d) && (d = h);
|
||||
(!d || d !== h) && p.push({
|
||||
elem: h,
|
||||
handleObj: g,
|
||||
level: m.level
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
for (j = 0, k = p.length; j < k; j++) {
|
||||
e = p[j];
|
||||
if (c && e.level > c) break;
|
||||
a.currentTarget = e.elem, a.data = e.handleObj.data, a.handleObj = e.handleObj, o = e.handleObj.origHandler.apply(e.elem, arguments);
|
||||
if (o === !1 || a.isPropagationStopped()) {
|
||||
c = e.level, o === !1 && (b = !1);
|
||||
if (a.isImmediatePropagationStopped()) break
|
||||
}
|
||||
}
|
||||
return b
|
||||
}
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "dragleave",
|
||||
|
@ -264,9 +274,10 @@ const TEST_DATA = [
|
|||
"jQuery",
|
||||
"Live"
|
||||
],
|
||||
handler: "function liveDivDragLeave() {\n" +
|
||||
" alert(3);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function liveDivDragLeave() {
|
||||
alert(3);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "dragleave",
|
||||
|
@ -275,42 +286,43 @@ const TEST_DATA = [
|
|||
"jQuery",
|
||||
"Live"
|
||||
],
|
||||
handler: "function M(a) {\n" +
|
||||
" var b, c, d, e, g, h, i, j, k, l, m, n, o, p = [],\n" +
|
||||
" q = [],\n" +
|
||||
" r = f._data(this, \"events\");\n" +
|
||||
" if (!(a.liveFired === this || !r || !r.live || a.target.disabled || a.button && a.type === \"click\")) {\n" +
|
||||
" a.namespace && (n = new RegExp(\"(^|\\\\.)\" + a.namespace.split(\".\").join(\"\\\\.(?:.*\\\\.)?\") + \"(\\\\.|$)\")), a.liveFired = this;\n" +
|
||||
" var s = r.live.slice(0);\n" +
|
||||
" for (i = 0; i < s.length; i++) g = s[i], g.origType.replace(x, \"\") === a.type ? q.push(g.selector) : s.splice(i--, 1);\n" +
|
||||
" e = f(a.target).closest(q, a.currentTarget);\n" +
|
||||
" for (j = 0, k = e.length; j < k; j++) {\n" +
|
||||
" m = e[j];\n" +
|
||||
" for (i = 0; i < s.length; i++) {\n" +
|
||||
" g = s[i];\n" +
|
||||
" if (m.selector === g.selector && (!n || n.test(g.namespace)) && !m.elem.disabled) {\n" +
|
||||
" h = m.elem, d = null;\n" +
|
||||
" if (g.preType === \"mouseenter\" || g.preType === \"mouseleave\") a.type = g.preType, d = f(a.relatedTarget).closest(g.selector)[0], d && f.contains(h, d) && (d = h);\n" +
|
||||
" (!d || d !== h) && p.push({\n" +
|
||||
" elem: h,\n" +
|
||||
" handleObj: g,\n" +
|
||||
" level: m.level\n" +
|
||||
" })\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" for (j = 0, k = p.length; j < k; j++) {\n" +
|
||||
" e = p[j];\n" +
|
||||
" if (c && e.level > c) break;\n" +
|
||||
" a.currentTarget = e.elem, a.data = e.handleObj.data, a.handleObj = e.handleObj, o = e.handleObj.origHandler.apply(e.elem, arguments);\n" +
|
||||
" if (o === !1 || a.isPropagationStopped()) {\n" +
|
||||
" c = e.level, o === !1 && (b = !1);\n" +
|
||||
" if (a.isImmediatePropagationStopped()) break\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" return b\n" +
|
||||
" }\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function M(a) {
|
||||
var b, c, d, e, g, h, i, j, k, l, m, n, o, p = [],
|
||||
q = [],
|
||||
r = f._data(this, "events");
|
||||
if (!(a.liveFired === this || !r || !r.live || a.target.disabled || a.button && a.type === "click")) {
|
||||
a.namespace && (n = new RegExp("(^|\\\\.)" + a.namespace.split(".").join("\\\\.(?:.*\\\\.)?") + "(\\\\.|$)")), a.liveFired = this;
|
||||
var s = r.live.slice(0);
|
||||
for (i = 0; i < s.length; i++) g = s[i], g.origType.replace(x, "") === a.type ? q.push(g.selector) : s.splice(i--, 1);
|
||||
e = f(a.target).closest(q, a.currentTarget);
|
||||
for (j = 0, k = e.length; j < k; j++) {
|
||||
m = e[j];
|
||||
for (i = 0; i < s.length; i++) {
|
||||
g = s[i];
|
||||
if (m.selector === g.selector && (!n || n.test(g.namespace)) && !m.elem.disabled) {
|
||||
h = m.elem, d = null;
|
||||
if (g.preType === "mouseenter" || g.preType === "mouseleave") a.type = g.preType, d = f(a.relatedTarget).closest(g.selector)[0], d && f.contains(h, d) && (d = h);
|
||||
(!d || d !== h) && p.push({
|
||||
elem: h,
|
||||
handleObj: g,
|
||||
level: m.level
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
for (j = 0, k = p.length; j < k; j++) {
|
||||
e = p[j];
|
||||
if (c && e.level > c) break;
|
||||
a.currentTarget = e.elem, a.data = e.handleObj.data, a.handleObj = e.handleObj, o = e.handleObj.origHandler.apply(e.elem, arguments);
|
||||
if (o === !1 || a.isPropagationStopped()) {
|
||||
c = e.level, o === !1 && (b = !1);
|
||||
if (a.isImmediatePropagationStopped()) break
|
||||
}
|
||||
}
|
||||
return b
|
||||
}
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "dragstart",
|
||||
|
@ -319,9 +331,10 @@ const TEST_DATA = [
|
|||
"jQuery",
|
||||
"Live"
|
||||
],
|
||||
handler: "function liveDivDragStart() {\n" +
|
||||
" alert(2);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function liveDivDragStart() {
|
||||
alert(2);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "dragstart",
|
||||
|
@ -330,42 +343,43 @@ const TEST_DATA = [
|
|||
"jQuery",
|
||||
"Live"
|
||||
],
|
||||
handler: "function M(a) {\n" +
|
||||
" var b, c, d, e, g, h, i, j, k, l, m, n, o, p = [],\n" +
|
||||
" q = [],\n" +
|
||||
" r = f._data(this, \"events\");\n" +
|
||||
" if (!(a.liveFired === this || !r || !r.live || a.target.disabled || a.button && a.type === \"click\")) {\n" +
|
||||
" a.namespace && (n = new RegExp(\"(^|\\\\.)\" + a.namespace.split(\".\").join(\"\\\\.(?:.*\\\\.)?\") + \"(\\\\.|$)\")), a.liveFired = this;\n" +
|
||||
" var s = r.live.slice(0);\n" +
|
||||
" for (i = 0; i < s.length; i++) g = s[i], g.origType.replace(x, \"\") === a.type ? q.push(g.selector) : s.splice(i--, 1);\n" +
|
||||
" e = f(a.target).closest(q, a.currentTarget);\n" +
|
||||
" for (j = 0, k = e.length; j < k; j++) {\n" +
|
||||
" m = e[j];\n" +
|
||||
" for (i = 0; i < s.length; i++) {\n" +
|
||||
" g = s[i];\n" +
|
||||
" if (m.selector === g.selector && (!n || n.test(g.namespace)) && !m.elem.disabled) {\n" +
|
||||
" h = m.elem, d = null;\n" +
|
||||
" if (g.preType === \"mouseenter\" || g.preType === \"mouseleave\") a.type = g.preType, d = f(a.relatedTarget).closest(g.selector)[0], d && f.contains(h, d) && (d = h);\n" +
|
||||
" (!d || d !== h) && p.push({\n" +
|
||||
" elem: h,\n" +
|
||||
" handleObj: g,\n" +
|
||||
" level: m.level\n" +
|
||||
" })\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" for (j = 0, k = p.length; j < k; j++) {\n" +
|
||||
" e = p[j];\n" +
|
||||
" if (c && e.level > c) break;\n" +
|
||||
" a.currentTarget = e.elem, a.data = e.handleObj.data, a.handleObj = e.handleObj, o = e.handleObj.origHandler.apply(e.elem, arguments);\n" +
|
||||
" if (o === !1 || a.isPropagationStopped()) {\n" +
|
||||
" c = e.level, o === !1 && (b = !1);\n" +
|
||||
" if (a.isImmediatePropagationStopped()) break\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" return b\n" +
|
||||
" }\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function M(a) {
|
||||
var b, c, d, e, g, h, i, j, k, l, m, n, o, p = [],
|
||||
q = [],
|
||||
r = f._data(this, "events");
|
||||
if (!(a.liveFired === this || !r || !r.live || a.target.disabled || a.button && a.type === "click")) {
|
||||
a.namespace && (n = new RegExp("(^|\\\\.)" + a.namespace.split(".").join("\\\\.(?:.*\\\\.)?") + "(\\\\.|$)")), a.liveFired = this;
|
||||
var s = r.live.slice(0);
|
||||
for (i = 0; i < s.length; i++) g = s[i], g.origType.replace(x, "") === a.type ? q.push(g.selector) : s.splice(i--, 1);
|
||||
e = f(a.target).closest(q, a.currentTarget);
|
||||
for (j = 0, k = e.length; j < k; j++) {
|
||||
m = e[j];
|
||||
for (i = 0; i < s.length; i++) {
|
||||
g = s[i];
|
||||
if (m.selector === g.selector && (!n || n.test(g.namespace)) && !m.elem.disabled) {
|
||||
h = m.elem, d = null;
|
||||
if (g.preType === "mouseenter" || g.preType === "mouseleave") a.type = g.preType, d = f(a.relatedTarget).closest(g.selector)[0], d && f.contains(h, d) && (d = h);
|
||||
(!d || d !== h) && p.push({
|
||||
elem: h,
|
||||
handleObj: g,
|
||||
level: m.level
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
for (j = 0, k = p.length; j < k; j++) {
|
||||
e = p[j];
|
||||
if (c && e.level > c) break;
|
||||
a.currentTarget = e.elem, a.data = e.handleObj.data, a.handleObj = e.handleObj, o = e.handleObj.origHandler.apply(e.elem, arguments);
|
||||
if (o === !1 || a.isPropagationStopped()) {
|
||||
c = e.level, o === !1 && (b = !1);
|
||||
if (a.isImmediatePropagationStopped()) break
|
||||
}
|
||||
}
|
||||
return b
|
||||
}
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -26,9 +26,10 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "function() {\n" +
|
||||
" c.removeEventListener(\"DOMContentLoaded\", C, !1), e.ready()\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function() {
|
||||
c.removeEventListener("DOMContentLoaded", C, !1), e.ready()
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "load",
|
||||
|
@ -37,59 +38,60 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "() => {\n" +
|
||||
" var handler1 = function liveDivDblClick() {\n" +
|
||||
" alert(1);\n" +
|
||||
" };\n" +
|
||||
" var handler2 = function liveDivDragStart() {\n" +
|
||||
" alert(2);\n" +
|
||||
" };\n" +
|
||||
" var handler3 = function liveDivDragLeave() {\n" +
|
||||
" alert(3);\n" +
|
||||
" };\n" +
|
||||
" var handler4 = function liveDivDragEnd() {\n" +
|
||||
" alert(4);\n" +
|
||||
" };\n" +
|
||||
" var handler5 = function liveDivDrop() {\n" +
|
||||
" alert(5);\n" +
|
||||
" };\n" +
|
||||
" var handler6 = function liveDivDragOver() {\n" +
|
||||
" alert(6);\n" +
|
||||
" };\n" +
|
||||
" var handler7 = function divClick1() {\n" +
|
||||
" alert(7);\n" +
|
||||
" };\n" +
|
||||
" var handler8 = function divClick2() {\n" +
|
||||
" alert(8);\n" +
|
||||
" };\n" +
|
||||
" var handler9 = function divKeyDown() {\n" +
|
||||
" alert(9);\n" +
|
||||
" };\n" +
|
||||
" var handler10 = function divDragOut() {\n" +
|
||||
" alert(10);\n" +
|
||||
" };\n" +
|
||||
"\n" +
|
||||
" if ($(\"#livediv\").live) {\n" +
|
||||
" $(\"#livediv\").live(\"dblclick\", handler1);\n" +
|
||||
" $(\"#livediv\").live(\"dragstart\", handler2);\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" if ($(\"#livediv\").delegate) {\n" +
|
||||
" $(document).delegate(\"#livediv\", \"dragleave\", handler3);\n" +
|
||||
" $(document).delegate(\"#livediv\", \"dragend\", handler4);\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" if ($(\"#livediv\").on) {\n" +
|
||||
" $(document).on(\"drop\", \"#livediv\", handler5);\n" +
|
||||
" $(document).on(\"dragover\", \"#livediv\", handler6);\n" +
|
||||
" $(document).on(\"dragout\", \"#livediv:xxxxx\", handler10);\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" var div = $(\"div\")[0];\n" +
|
||||
" $(div).click(handler7);\n" +
|
||||
" $(div).click(handler8);\n" +
|
||||
" $(div).keydown(handler9);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
() => {
|
||||
var handler1 = function liveDivDblClick() {
|
||||
alert(1);
|
||||
};
|
||||
var handler2 = function liveDivDragStart() {
|
||||
alert(2);
|
||||
};
|
||||
var handler3 = function liveDivDragLeave() {
|
||||
alert(3);
|
||||
};
|
||||
var handler4 = function liveDivDragEnd() {
|
||||
alert(4);
|
||||
};
|
||||
var handler5 = function liveDivDrop() {
|
||||
alert(5);
|
||||
};
|
||||
var handler6 = function liveDivDragOver() {
|
||||
alert(6);
|
||||
};
|
||||
var handler7 = function divClick1() {
|
||||
alert(7);
|
||||
};
|
||||
var handler8 = function divClick2() {
|
||||
alert(8);
|
||||
};
|
||||
var handler9 = function divKeyDown() {
|
||||
alert(9);
|
||||
};
|
||||
var handler10 = function divDragOut() {
|
||||
alert(10);
|
||||
};
|
||||
|
||||
if ($("#livediv").live) {
|
||||
$("#livediv").live("dblclick", handler1);
|
||||
$("#livediv").live("dragstart", handler2);
|
||||
}
|
||||
|
||||
if ($("#livediv").delegate) {
|
||||
$(document).delegate("#livediv", "dragleave", handler3);
|
||||
$(document).delegate("#livediv", "dragend", handler4);
|
||||
}
|
||||
|
||||
if ($("#livediv").on) {
|
||||
$(document).on("drop", "#livediv", handler5);
|
||||
$(document).on("dragover", "#livediv", handler6);
|
||||
$(document).on("dragout", "#livediv:xxxxx", handler10);
|
||||
}
|
||||
|
||||
var div = $("div")[0];
|
||||
$(div).click(handler7);
|
||||
$(div).click(handler8);
|
||||
$(div).keydown(handler9);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "load",
|
||||
|
@ -98,14 +100,15 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "function(a) {\n" +
|
||||
" if (a === !0 && !--e.readyWait || a !== !0 && !e.isReady) {\n" +
|
||||
" if (!c.body) return setTimeout(e.ready, 1);\n" +
|
||||
" e.isReady = !0;\n" +
|
||||
" if (a !== !0 && --e.readyWait > 0) return;\n" +
|
||||
" B.fireWith(c, [e]), e.fn.trigger && e(c).trigger(\"ready\").unbind(\"ready\")\n" +
|
||||
" }\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function(a) {
|
||||
if (a === !0 && !--e.readyWait || a !== !0 && !e.isReady) {
|
||||
if (!c.body) return setTimeout(e.ready, 1);
|
||||
e.isReady = !0;
|
||||
if (a !== !0 && --e.readyWait > 0) return;
|
||||
B.fireWith(c, [e]), e.fn.trigger && e(c).trigger("ready").unbind("ready")
|
||||
}
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -118,9 +121,10 @@ const TEST_DATA = [
|
|||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function divClick1() {\n" +
|
||||
" alert(7);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function divClick1() {
|
||||
alert(7);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "click",
|
||||
|
@ -128,9 +132,10 @@ const TEST_DATA = [
|
|||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function divClick2() {\n" +
|
||||
" alert(8);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function divClick2() {
|
||||
alert(8);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "keydown",
|
||||
|
@ -138,9 +143,10 @@ const TEST_DATA = [
|
|||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function divKeyDown() {\n" +
|
||||
" alert(9);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function divKeyDown() {
|
||||
alert(9);
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -154,9 +160,10 @@ const TEST_DATA = [
|
|||
"jQuery",
|
||||
"Live"
|
||||
],
|
||||
handler: "function liveDivDblClick() {\n" +
|
||||
" alert(1);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function liveDivDblClick() {
|
||||
alert(1);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "dragend",
|
||||
|
@ -165,9 +172,10 @@ const TEST_DATA = [
|
|||
"jQuery",
|
||||
"Live"
|
||||
],
|
||||
handler: "function liveDivDragEnd() {\n" +
|
||||
" alert(4);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function liveDivDragEnd() {
|
||||
alert(4);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "dragleave",
|
||||
|
@ -176,9 +184,10 @@ const TEST_DATA = [
|
|||
"jQuery",
|
||||
"Live"
|
||||
],
|
||||
handler: "function liveDivDragLeave() {\n" +
|
||||
" alert(3);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function liveDivDragLeave() {
|
||||
alert(3);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "dragover",
|
||||
|
@ -187,9 +196,10 @@ const TEST_DATA = [
|
|||
"jQuery",
|
||||
"Live"
|
||||
],
|
||||
handler: "function liveDivDragOver() {\n" +
|
||||
" alert(6);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function liveDivDragOver() {
|
||||
alert(6);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "dragstart",
|
||||
|
@ -198,9 +208,10 @@ const TEST_DATA = [
|
|||
"jQuery",
|
||||
"Live"
|
||||
],
|
||||
handler: "function liveDivDragStart() {\n" +
|
||||
" alert(2);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function liveDivDragStart() {
|
||||
alert(2);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "drop",
|
||||
|
@ -209,9 +220,10 @@ const TEST_DATA = [
|
|||
"jQuery",
|
||||
"Live"
|
||||
],
|
||||
handler: "function liveDivDrop() {\n" +
|
||||
" alert(5);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function liveDivDrop() {
|
||||
alert(5);
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -26,59 +26,60 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "() => {\n" +
|
||||
" var handler1 = function liveDivDblClick() {\n" +
|
||||
" alert(1);\n" +
|
||||
" };\n" +
|
||||
" var handler2 = function liveDivDragStart() {\n" +
|
||||
" alert(2);\n" +
|
||||
" };\n" +
|
||||
" var handler3 = function liveDivDragLeave() {\n" +
|
||||
" alert(3);\n" +
|
||||
" };\n" +
|
||||
" var handler4 = function liveDivDragEnd() {\n" +
|
||||
" alert(4);\n" +
|
||||
" };\n" +
|
||||
" var handler5 = function liveDivDrop() {\n" +
|
||||
" alert(5);\n" +
|
||||
" };\n" +
|
||||
" var handler6 = function liveDivDragOver() {\n" +
|
||||
" alert(6);\n" +
|
||||
" };\n" +
|
||||
" var handler7 = function divClick1() {\n" +
|
||||
" alert(7);\n" +
|
||||
" };\n" +
|
||||
" var handler8 = function divClick2() {\n" +
|
||||
" alert(8);\n" +
|
||||
" };\n" +
|
||||
" var handler9 = function divKeyDown() {\n" +
|
||||
" alert(9);\n" +
|
||||
" };\n" +
|
||||
" var handler10 = function divDragOut() {\n" +
|
||||
" alert(10);\n" +
|
||||
" };\n" +
|
||||
"\n" +
|
||||
" if ($(\"#livediv\").live) {\n" +
|
||||
" $(\"#livediv\").live(\"dblclick\", handler1);\n" +
|
||||
" $(\"#livediv\").live(\"dragstart\", handler2);\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" if ($(\"#livediv\").delegate) {\n" +
|
||||
" $(document).delegate(\"#livediv\", \"dragleave\", handler3);\n" +
|
||||
" $(document).delegate(\"#livediv\", \"dragend\", handler4);\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" if ($(\"#livediv\").on) {\n" +
|
||||
" $(document).on(\"drop\", \"#livediv\", handler5);\n" +
|
||||
" $(document).on(\"dragover\", \"#livediv\", handler6);\n" +
|
||||
" $(document).on(\"dragout\", \"#livediv:xxxxx\", handler10);\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" var div = $(\"div\")[0];\n" +
|
||||
" $(div).click(handler7);\n" +
|
||||
" $(div).click(handler8);\n" +
|
||||
" $(div).keydown(handler9);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
() => {
|
||||
var handler1 = function liveDivDblClick() {
|
||||
alert(1);
|
||||
};
|
||||
var handler2 = function liveDivDragStart() {
|
||||
alert(2);
|
||||
};
|
||||
var handler3 = function liveDivDragLeave() {
|
||||
alert(3);
|
||||
};
|
||||
var handler4 = function liveDivDragEnd() {
|
||||
alert(4);
|
||||
};
|
||||
var handler5 = function liveDivDrop() {
|
||||
alert(5);
|
||||
};
|
||||
var handler6 = function liveDivDragOver() {
|
||||
alert(6);
|
||||
};
|
||||
var handler7 = function divClick1() {
|
||||
alert(7);
|
||||
};
|
||||
var handler8 = function divClick2() {
|
||||
alert(8);
|
||||
};
|
||||
var handler9 = function divKeyDown() {
|
||||
alert(9);
|
||||
};
|
||||
var handler10 = function divDragOut() {
|
||||
alert(10);
|
||||
};
|
||||
|
||||
if ($("#livediv").live) {
|
||||
$("#livediv").live("dblclick", handler1);
|
||||
$("#livediv").live("dragstart", handler2);
|
||||
}
|
||||
|
||||
if ($("#livediv").delegate) {
|
||||
$(document).delegate("#livediv", "dragleave", handler3);
|
||||
$(document).delegate("#livediv", "dragend", handler4);
|
||||
}
|
||||
|
||||
if ($("#livediv").on) {
|
||||
$(document).on("drop", "#livediv", handler5);
|
||||
$(document).on("dragover", "#livediv", handler6);
|
||||
$(document).on("dragout", "#livediv:xxxxx", handler10);
|
||||
}
|
||||
|
||||
var div = $("div")[0];
|
||||
$(div).click(handler7);
|
||||
$(div).click(handler8);
|
||||
$(div).keydown(handler9);
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -91,9 +92,10 @@ const TEST_DATA = [
|
|||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function divClick1() {\n" +
|
||||
" alert(7);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function divClick1() {
|
||||
alert(7);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "click",
|
||||
|
@ -101,9 +103,10 @@ const TEST_DATA = [
|
|||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function divClick2() {\n" +
|
||||
" alert(8);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function divClick2() {
|
||||
alert(8);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "keydown",
|
||||
|
@ -111,9 +114,10 @@ const TEST_DATA = [
|
|||
attributes: [
|
||||
"jQuery"
|
||||
],
|
||||
handler: "function divKeyDown() {\n" +
|
||||
" alert(9);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function divKeyDown() {
|
||||
alert(9);
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -127,9 +131,10 @@ const TEST_DATA = [
|
|||
"jQuery",
|
||||
"Live"
|
||||
],
|
||||
handler: "function liveDivDragEnd() {\n" +
|
||||
" alert(4);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function liveDivDragEnd() {
|
||||
alert(4);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "dragleave",
|
||||
|
@ -138,9 +143,10 @@ const TEST_DATA = [
|
|||
"jQuery",
|
||||
"Live"
|
||||
],
|
||||
handler: "function liveDivDragLeave() {\n" +
|
||||
" alert(3);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function liveDivDragLeave() {
|
||||
alert(3);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "dragover",
|
||||
|
@ -149,9 +155,10 @@ const TEST_DATA = [
|
|||
"jQuery",
|
||||
"Live"
|
||||
],
|
||||
handler: "function liveDivDragOver() {\n" +
|
||||
" alert(6);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function liveDivDragOver() {
|
||||
alert(6);
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "drop",
|
||||
|
@ -160,9 +167,10 @@ const TEST_DATA = [
|
|||
"jQuery",
|
||||
"Live"
|
||||
],
|
||||
handler: "function liveDivDrop() {\n" +
|
||||
" alert(5);\n" +
|
||||
"}"
|
||||
handler: `
|
||||
function liveDivDrop() {
|
||||
alert(5);
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -27,7 +27,7 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "function emptyFunction() {}"
|
||||
handler: `function emptyFunction() {}`
|
||||
},
|
||||
{
|
||||
type: "onClick",
|
||||
|
@ -36,10 +36,10 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"React"
|
||||
],
|
||||
handler:
|
||||
`function() {
|
||||
alert("inlineFunction");
|
||||
}`
|
||||
handler: `
|
||||
function() {
|
||||
alert("inlineFunction");
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -53,7 +53,7 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "function emptyFunction() {}"
|
||||
handler: `function emptyFunction() {}`
|
||||
},
|
||||
{
|
||||
type: "onClick",
|
||||
|
@ -62,10 +62,10 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"React"
|
||||
],
|
||||
handler:
|
||||
`function externalFunction() {
|
||||
alert("externalFunction");
|
||||
}`
|
||||
handler: `
|
||||
function externalFunction() {
|
||||
alert("externalFunction");
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -79,7 +79,7 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "function emptyFunction() {}"
|
||||
handler: `function emptyFunction() {}`
|
||||
},
|
||||
{
|
||||
type: "onClick",
|
||||
|
@ -88,10 +88,10 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"React"
|
||||
],
|
||||
handler:
|
||||
`function externalFunction() {
|
||||
alert("externalFunction");
|
||||
}`
|
||||
handler: `
|
||||
function externalFunction() {
|
||||
alert("externalFunction");
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "onMouseUp",
|
||||
|
@ -100,10 +100,10 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"React"
|
||||
],
|
||||
handler:
|
||||
`function() {
|
||||
alert("inlineFunction");
|
||||
}`
|
||||
handler: `
|
||||
function() {
|
||||
alert("inlineFunction");
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -117,10 +117,10 @@ const TEST_DATA = [
|
|||
"Capturing",
|
||||
"React"
|
||||
],
|
||||
handler:
|
||||
`function externalCapturingFunction() {
|
||||
alert("externalCapturingFunction");
|
||||
}`
|
||||
handler: `
|
||||
function externalCapturingFunction() {
|
||||
alert("externalCapturingFunction");
|
||||
}`
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "function emptyFunction() {}"
|
||||
handler: `function emptyFunction() {}`
|
||||
},
|
||||
{
|
||||
type: "onClick",
|
||||
|
@ -37,10 +37,10 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"React"
|
||||
],
|
||||
handler:
|
||||
`function inlineFunction() {
|
||||
alert("inlineFunction");
|
||||
}`
|
||||
handler: `
|
||||
function inlineFunction() {
|
||||
alert("inlineFunction");
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -54,7 +54,7 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "function emptyFunction() {}"
|
||||
handler: `function emptyFunction() {}`
|
||||
},
|
||||
{
|
||||
type: "onClick",
|
||||
|
@ -63,10 +63,10 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"React"
|
||||
],
|
||||
handler:
|
||||
`function externalFunction() {
|
||||
alert("externalFunction");
|
||||
}`
|
||||
handler: `
|
||||
function externalFunction() {
|
||||
alert("externalFunction");
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -80,7 +80,7 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "function emptyFunction() {}"
|
||||
handler: `function emptyFunction() {}`
|
||||
},
|
||||
{
|
||||
type: "onClick",
|
||||
|
@ -89,10 +89,10 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"React"
|
||||
],
|
||||
handler:
|
||||
`function externalFunction() {
|
||||
alert("externalFunction");
|
||||
}`
|
||||
handler: `
|
||||
function externalFunction() {
|
||||
alert("externalFunction");
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "onMouseUp",
|
||||
|
@ -101,10 +101,10 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"React"
|
||||
],
|
||||
handler:
|
||||
`function inlineFunction() {
|
||||
alert("inlineFunction");
|
||||
}`
|
||||
handler: `
|
||||
function inlineFunction() {
|
||||
alert("inlineFunction");
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -118,10 +118,10 @@ const TEST_DATA = [
|
|||
"Capturing",
|
||||
"React"
|
||||
],
|
||||
handler:
|
||||
`function externalCapturingFunction() {
|
||||
alert("externalCapturingFunction");
|
||||
}`
|
||||
handler: `
|
||||
function externalCapturingFunction() {
|
||||
alert("externalCapturingFunction");
|
||||
}`
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "function() {}"
|
||||
handler: `function() {}`
|
||||
},
|
||||
{
|
||||
type: "onClick",
|
||||
|
@ -36,10 +36,10 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"React"
|
||||
],
|
||||
handler:
|
||||
`function() {
|
||||
alert("inlineFunction");
|
||||
}`
|
||||
handler: `
|
||||
function() {
|
||||
alert("inlineFunction");
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -53,7 +53,7 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "function() {}"
|
||||
handler: `function() {}`
|
||||
},
|
||||
{
|
||||
type: "onClick",
|
||||
|
@ -62,10 +62,10 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"React"
|
||||
],
|
||||
handler:
|
||||
`function externalFunction() {
|
||||
alert("externalFunction");
|
||||
}`
|
||||
handler: `
|
||||
function externalFunction() {
|
||||
alert("externalFunction");
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -79,7 +79,7 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "function() {}"
|
||||
handler: `function() {}`
|
||||
},
|
||||
{
|
||||
type: "onClick",
|
||||
|
@ -88,10 +88,10 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"React"
|
||||
],
|
||||
handler:
|
||||
`function externalFunction() {
|
||||
alert("externalFunction");
|
||||
}`
|
||||
handler: `
|
||||
function externalFunction() {
|
||||
alert("externalFunction");
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "onMouseUp",
|
||||
|
@ -100,10 +100,10 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"React"
|
||||
],
|
||||
handler:
|
||||
`function() {
|
||||
alert("inlineFunction");
|
||||
}`
|
||||
handler: `
|
||||
function() {
|
||||
alert("inlineFunction");
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -117,10 +117,10 @@ const TEST_DATA = [
|
|||
"Capturing",
|
||||
"React"
|
||||
],
|
||||
handler:
|
||||
`function externalCapturingFunction() {
|
||||
alert("externalCapturingFunction");
|
||||
}`
|
||||
handler: `
|
||||
function externalCapturingFunction() {
|
||||
alert("externalCapturingFunction");
|
||||
}`
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "function() {}"
|
||||
handler: `function() {}`
|
||||
},
|
||||
{
|
||||
type: "onClick",
|
||||
|
@ -37,10 +37,10 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"React"
|
||||
],
|
||||
handler:
|
||||
`function() {
|
||||
alert("inlineFunction");
|
||||
}`
|
||||
handler: `
|
||||
function() {
|
||||
alert("inlineFunction");
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -54,7 +54,7 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "function() {}"
|
||||
handler: `function() {}`
|
||||
},
|
||||
{
|
||||
type: "onClick",
|
||||
|
@ -63,10 +63,10 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"React"
|
||||
],
|
||||
handler:
|
||||
`function externalFunction() {
|
||||
alert("externalFunction");
|
||||
}`
|
||||
handler: `
|
||||
function externalFunction() {
|
||||
alert("externalFunction");
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -80,7 +80,7 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "function() {}"
|
||||
handler: `function() {}`
|
||||
},
|
||||
{
|
||||
type: "onClick",
|
||||
|
@ -89,10 +89,10 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"React"
|
||||
],
|
||||
handler:
|
||||
`function externalFunction() {
|
||||
alert("externalFunction");
|
||||
}`
|
||||
handler: `
|
||||
function externalFunction() {
|
||||
alert("externalFunction");
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "onMouseUp",
|
||||
|
@ -101,10 +101,10 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"React"
|
||||
],
|
||||
handler:
|
||||
`function() {
|
||||
alert("inlineFunction");
|
||||
}`
|
||||
handler: `
|
||||
function() {
|
||||
alert("inlineFunction");
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -118,10 +118,10 @@ const TEST_DATA = [
|
|||
"Capturing",
|
||||
"React"
|
||||
],
|
||||
handler:
|
||||
`function externalCapturingFunction() {
|
||||
alert("externalCapturingFunction");
|
||||
}`
|
||||
handler: `
|
||||
function externalCapturingFunction() {
|
||||
alert("externalCapturingFunction");
|
||||
}`
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "function() {}"
|
||||
handler: `function() {}`
|
||||
},
|
||||
{
|
||||
type: "onClick",
|
||||
|
@ -36,10 +36,10 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"React"
|
||||
],
|
||||
handler:
|
||||
`inlineFunction() {
|
||||
alert("inlineFunction");
|
||||
}`
|
||||
handler: `
|
||||
inlineFunction() {
|
||||
alert("inlineFunction");
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -53,7 +53,7 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "function() {}"
|
||||
handler: `function() {}`
|
||||
},
|
||||
{
|
||||
type: "onClick",
|
||||
|
@ -62,10 +62,10 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"React"
|
||||
],
|
||||
handler:
|
||||
`function externalFunction() {
|
||||
alert("externalFunction");
|
||||
}`
|
||||
handler: `
|
||||
function externalFunction() {
|
||||
alert("externalFunction");
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -79,7 +79,7 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "function() {}"
|
||||
handler: `function() {}`
|
||||
},
|
||||
{
|
||||
type: "onClick",
|
||||
|
@ -88,10 +88,10 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"React"
|
||||
],
|
||||
handler:
|
||||
`function externalFunction() {
|
||||
alert("externalFunction");
|
||||
}`
|
||||
handler: `
|
||||
function externalFunction() {
|
||||
alert("externalFunction");
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "onMouseUp",
|
||||
|
@ -100,10 +100,10 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"React"
|
||||
],
|
||||
handler:
|
||||
`inlineFunction() {
|
||||
alert("inlineFunction");
|
||||
}`
|
||||
handler: `
|
||||
inlineFunction() {
|
||||
alert("inlineFunction");
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -117,10 +117,10 @@ const TEST_DATA = [
|
|||
"Capturing",
|
||||
"React"
|
||||
],
|
||||
handler:
|
||||
`function externalCapturingFunction() {
|
||||
alert("externalCapturingFunction");
|
||||
}`
|
||||
handler: `
|
||||
function externalCapturingFunction() {
|
||||
alert("externalCapturingFunction");
|
||||
}`
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "function() {}"
|
||||
handler: `function() {}`
|
||||
},
|
||||
{
|
||||
type: "onClick",
|
||||
|
@ -37,10 +37,10 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"React"
|
||||
],
|
||||
handler:
|
||||
`function inlineFunction() {
|
||||
alert("inlineFunction");
|
||||
}`
|
||||
handler: `
|
||||
function inlineFunction() {
|
||||
alert("inlineFunction");
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -54,7 +54,7 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "function() {}"
|
||||
handler: `function() {}`
|
||||
},
|
||||
{
|
||||
type: "onClick",
|
||||
|
@ -63,10 +63,10 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"React"
|
||||
],
|
||||
handler:
|
||||
`function externalFunction() {
|
||||
alert("externalFunction");
|
||||
}`
|
||||
handler: `
|
||||
function externalFunction() {
|
||||
alert("externalFunction");
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -80,7 +80,7 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: "function() {}"
|
||||
handler: `function() {}`
|
||||
},
|
||||
{
|
||||
type: "onClick",
|
||||
|
@ -89,10 +89,10 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"React"
|
||||
],
|
||||
handler:
|
||||
`function externalFunction() {
|
||||
alert("externalFunction");
|
||||
}`
|
||||
handler: `
|
||||
function externalFunction() {
|
||||
alert("externalFunction");
|
||||
}`
|
||||
},
|
||||
{
|
||||
type: "onMouseUp",
|
||||
|
@ -101,10 +101,10 @@ const TEST_DATA = [
|
|||
"Bubbling",
|
||||
"React"
|
||||
],
|
||||
handler:
|
||||
`function inlineFunction() {
|
||||
alert("inlineFunction");
|
||||
}`
|
||||
handler: `
|
||||
function inlineFunction() {
|
||||
alert("inlineFunction");
|
||||
}`
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -118,10 +118,10 @@ const TEST_DATA = [
|
|||
"Capturing",
|
||||
"React"
|
||||
],
|
||||
handler:
|
||||
`function externalCapturingFunction() {
|
||||
alert("externalCapturingFunction");
|
||||
}`
|
||||
handler: `
|
||||
function externalCapturingFunction() {
|
||||
alert("externalCapturingFunction");
|
||||
}`
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
/* import-globals-from helper_diff.js */
|
||||
"use strict";
|
||||
|
||||
const beautify = require("devtools/shared/jsbeautify/beautify");
|
||||
|
||||
loadHelperScript("helper_diff.js");
|
||||
|
||||
/**
|
||||
|
@ -129,7 +131,10 @@ async function checkEventsForNode(test, inspector, testActor) {
|
|||
"We are in expanded state and icon changed");
|
||||
|
||||
const editor = tooltip.eventTooltip._eventEditors.get(contentBox).editor;
|
||||
testDiff(editor.getText(), expected[i].handler,
|
||||
const tidiedHandler = beautify.js(expected[i].handler, {
|
||||
"indent_size": 2,
|
||||
});
|
||||
testDiff(editor.getText(), tidiedHandler,
|
||||
"handler matches for " + cssSelector, ok);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,896 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// This file contains event collectors that are then used by developer tools in
|
||||
// order to find information about events affecting an HTML element.
|
||||
|
||||
"use strict";
|
||||
|
||||
const { Cu } = require("chrome");
|
||||
const Services = require("Services");
|
||||
const makeDebugger = require("devtools/server/actors/utils/make-debugger");
|
||||
|
||||
// eslint-disable-next-line
|
||||
const JQUERY_LIVE_REGEX = /return typeof \w+.*.event\.triggered[\s\S]*\.event\.(dispatch|handle).*arguments/;
|
||||
|
||||
const REACT_EVENT_NAMES = [
|
||||
"onAbort",
|
||||
"onAnimationEnd",
|
||||
"onAnimationIteration",
|
||||
"onAnimationStart",
|
||||
"onAuxClick",
|
||||
"onBeforeInput",
|
||||
"onBlur",
|
||||
"onCanPlay",
|
||||
"onCanPlayThrough",
|
||||
"onCancel",
|
||||
"onChange",
|
||||
"onClick",
|
||||
"onClose",
|
||||
"onCompositionEnd",
|
||||
"onCompositionStart",
|
||||
"onCompositionUpdate",
|
||||
"onContextMenu",
|
||||
"onCopy",
|
||||
"onCut",
|
||||
"onDoubleClick",
|
||||
"onDrag",
|
||||
"onDragEnd",
|
||||
"onDragEnter",
|
||||
"onDragExit",
|
||||
"onDragLeave",
|
||||
"onDragOver",
|
||||
"onDragStart",
|
||||
"onDrop",
|
||||
"onDurationChange",
|
||||
"onEmptied",
|
||||
"onEncrypted",
|
||||
"onEnded",
|
||||
"onError",
|
||||
"onFocus",
|
||||
"onGotPointerCapture",
|
||||
"onInput",
|
||||
"onInvalid",
|
||||
"onKeyDown",
|
||||
"onKeyPress",
|
||||
"onKeyUp",
|
||||
"onLoad",
|
||||
"onLoadStart",
|
||||
"onLoadedData",
|
||||
"onLoadedMetadata",
|
||||
"onLostPointerCapture",
|
||||
"onMouseDown",
|
||||
"onMouseEnter",
|
||||
"onMouseLeave",
|
||||
"onMouseMove",
|
||||
"onMouseOut",
|
||||
"onMouseOver",
|
||||
"onMouseUp",
|
||||
"onPaste",
|
||||
"onPause",
|
||||
"onPlay",
|
||||
"onPlaying",
|
||||
"onPointerCancel",
|
||||
"onPointerDown",
|
||||
"onPointerEnter",
|
||||
"onPointerLeave",
|
||||
"onPointerMove",
|
||||
"onPointerOut",
|
||||
"onPointerOver",
|
||||
"onPointerUp",
|
||||
"onProgress",
|
||||
"onRateChange",
|
||||
"onReset",
|
||||
"onScroll",
|
||||
"onSeeked",
|
||||
"onSeeking",
|
||||
"onSelect",
|
||||
"onStalled",
|
||||
"onSubmit",
|
||||
"onSuspend",
|
||||
"onTimeUpdate",
|
||||
"onToggle",
|
||||
"onTouchCancel",
|
||||
"onTouchEnd",
|
||||
"onTouchMove",
|
||||
"onTouchStart",
|
||||
"onTransitionEnd",
|
||||
"onVolumeChange",
|
||||
"onWaiting",
|
||||
"onWheel",
|
||||
"onAbortCapture",
|
||||
"onAnimationEndCapture",
|
||||
"onAnimationIterationCapture",
|
||||
"onAnimationStartCapture",
|
||||
"onAuxClickCapture",
|
||||
"onBeforeInputCapture",
|
||||
"onBlurCapture",
|
||||
"onCanPlayCapture",
|
||||
"onCanPlayThroughCapture",
|
||||
"onCancelCapture",
|
||||
"onChangeCapture",
|
||||
"onClickCapture",
|
||||
"onCloseCapture",
|
||||
"onCompositionEndCapture",
|
||||
"onCompositionStartCapture",
|
||||
"onCompositionUpdateCapture",
|
||||
"onContextMenuCapture",
|
||||
"onCopyCapture",
|
||||
"onCutCapture",
|
||||
"onDoubleClickCapture",
|
||||
"onDragCapture",
|
||||
"onDragEndCapture",
|
||||
"onDragEnterCapture",
|
||||
"onDragExitCapture",
|
||||
"onDragLeaveCapture",
|
||||
"onDragOverCapture",
|
||||
"onDragStartCapture",
|
||||
"onDropCapture",
|
||||
"onDurationChangeCapture",
|
||||
"onEmptiedCapture",
|
||||
"onEncryptedCapture",
|
||||
"onEndedCapture",
|
||||
"onErrorCapture",
|
||||
"onFocusCapture",
|
||||
"onGotPointerCaptureCapture",
|
||||
"onInputCapture",
|
||||
"onInvalidCapture",
|
||||
"onKeyDownCapture",
|
||||
"onKeyPressCapture",
|
||||
"onKeyUpCapture",
|
||||
"onLoadCapture",
|
||||
"onLoadStartCapture",
|
||||
"onLoadedDataCapture",
|
||||
"onLoadedMetadataCapture",
|
||||
"onLostPointerCaptureCapture",
|
||||
"onMouseDownCapture",
|
||||
"onMouseEnterCapture",
|
||||
"onMouseLeaveCapture",
|
||||
"onMouseMoveCapture",
|
||||
"onMouseOutCapture",
|
||||
"onMouseOverCapture",
|
||||
"onMouseUpCapture",
|
||||
"onPasteCapture",
|
||||
"onPauseCapture",
|
||||
"onPlayCapture",
|
||||
"onPlayingCapture",
|
||||
"onPointerCancelCapture",
|
||||
"onPointerDownCapture",
|
||||
"onPointerEnterCapture",
|
||||
"onPointerLeaveCapture",
|
||||
"onPointerMoveCapture",
|
||||
"onPointerOutCapture",
|
||||
"onPointerOverCapture",
|
||||
"onPointerUpCapture",
|
||||
"onProgressCapture",
|
||||
"onRateChangeCapture",
|
||||
"onResetCapture",
|
||||
"onScrollCapture",
|
||||
"onSeekedCapture",
|
||||
"onSeekingCapture",
|
||||
"onSelectCapture",
|
||||
"onStalledCapture",
|
||||
"onSubmitCapture",
|
||||
"onSuspendCapture",
|
||||
"onTimeUpdateCapture",
|
||||
"onToggleCapture",
|
||||
"onTouchCancelCapture",
|
||||
"onTouchEndCapture",
|
||||
"onTouchMoveCapture",
|
||||
"onTouchStartCapture",
|
||||
"onTransitionEndCapture",
|
||||
"onVolumeChangeCapture",
|
||||
"onWaitingCapture",
|
||||
"onWheelCapture",
|
||||
];
|
||||
|
||||
/**
|
||||
* The base class that all the enent collectors should be based upon.
|
||||
*/
|
||||
class MainEventCollector {
|
||||
/**
|
||||
* Check if a node has any event listeners attached. Please do not override
|
||||
* this method... your getListeners() implementation needs to have the
|
||||
* following signature:
|
||||
* `getListeners(node, {checkOnly} = {})`
|
||||
*
|
||||
* @param {DOMNode} node
|
||||
* The not for which we want to check for event listeners.
|
||||
* @return {Boolean}
|
||||
* true if the node has event listeners, false otherwise.
|
||||
*/
|
||||
hasListeners(node) {
|
||||
return this.getListeners(node, {
|
||||
checkOnly: true,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all listeners for a node. This method must be overridden.
|
||||
*
|
||||
* @param {DOMNode} node
|
||||
* The not for which we want to get event listeners.
|
||||
* @param {Object} options
|
||||
* An object for passing in options.
|
||||
* @param {Boolean} [options.checkOnly = false]
|
||||
* Don't get any listeners but return true when the first event is
|
||||
* found.
|
||||
* @return {Array}
|
||||
* An array of event handlers.
|
||||
*/
|
||||
getListeners(node, {checkOnly}) {
|
||||
throw new Error("You have to implement the method getListeners()!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get unfiltered DOM Event listeners for a node.
|
||||
* NOTE: These listeners may contain invalid events and events based
|
||||
* on C++ rather than JavaScript.
|
||||
*
|
||||
* @param {DOMNode} node
|
||||
* The node for which we want to get unfiltered event listeners.
|
||||
* @return {Array}
|
||||
* An array of unfiltered event listeners or an empty array
|
||||
*/
|
||||
getDOMListeners(node) {
|
||||
if (typeof node.nodeName !== "undefined" && node.nodeName.toLowerCase() === "html") {
|
||||
const winListeners =
|
||||
Services.els.getListenerInfoFor(node.ownerGlobal) || [];
|
||||
const docElementListeners =
|
||||
Services.els.getListenerInfoFor(node) || [];
|
||||
const docListeners =
|
||||
Services.els.getListenerInfoFor(node.parentNode) || [];
|
||||
|
||||
return [...winListeners, ...docElementListeners, ...docListeners];
|
||||
}
|
||||
return Services.els.getListenerInfoFor(node) || [];
|
||||
}
|
||||
|
||||
getJQuery(node) {
|
||||
const global = this.unwrap(node.ownerGlobal);
|
||||
const hasJQuery = global.jQuery && global.jQuery.fn && global.jQuery.fn.jquery;
|
||||
|
||||
if (hasJQuery) {
|
||||
return global.jQuery;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
unwrap(obj) {
|
||||
return Cu.isXrayWrapper(obj) ? obj.wrappedJSObject : obj;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or detect DOM events. These may include DOM events created by libraries
|
||||
* that enable their custom events to work. At this point we are unable to
|
||||
* effectively filter them as they may be proxied or wrapped. Although we know
|
||||
* there is an event, we may not know the true contents until it goes
|
||||
* through `processHandlerForEvent()`.
|
||||
*/
|
||||
class DOMEventCollector extends MainEventCollector {
|
||||
getListeners(node, {checkOnly} = {}) {
|
||||
const handlers = [];
|
||||
const listeners = this.getDOMListeners(node);
|
||||
|
||||
for (const listener of listeners) {
|
||||
// Ignore listeners without a type, e.g.
|
||||
// node.addEventListener("", function() {})
|
||||
if (!listener.type) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get the listener object, either a Function or an Object.
|
||||
const obj = listener.listenerObject;
|
||||
|
||||
// Ignore listeners without any listener, e.g.
|
||||
// node.addEventListener("mouseover", null);
|
||||
if (!obj) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let handler = null;
|
||||
|
||||
// An object without a valid handleEvent is not a valid listener.
|
||||
if (typeof obj === "object") {
|
||||
const unwrapped = this.unwrap(obj);
|
||||
if (typeof unwrapped.handleEvent === "function") {
|
||||
handler = Cu.unwaiveXrays(unwrapped.handleEvent);
|
||||
}
|
||||
} else if (typeof obj === "function") {
|
||||
// Ignore DOM events used to trigger jQuery events as they are only
|
||||
// useful to the developers of the jQuery library.
|
||||
if (JQUERY_LIVE_REGEX.test(obj.toString())) {
|
||||
continue;
|
||||
}
|
||||
// Otherwise, the other valid listener type is function.
|
||||
handler = obj;
|
||||
}
|
||||
|
||||
// Ignore listeners that have no handler.
|
||||
if (!handler) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If this is checking if a node has any listeners then we have found one
|
||||
// so return now.
|
||||
if (checkOnly) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const eventInfo = {
|
||||
capturing: listener.capturing,
|
||||
type: listener.type,
|
||||
handler: handler,
|
||||
};
|
||||
|
||||
handlers.push(eventInfo);
|
||||
}
|
||||
|
||||
// If this is checking if a node has any listeners then none were found so
|
||||
// return false.
|
||||
if (checkOnly) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or detect jQuery events.
|
||||
*/
|
||||
class JQueryEventCollector extends MainEventCollector {
|
||||
getListeners(node, {checkOnly} = {}) {
|
||||
const jQuery = this.getJQuery(node);
|
||||
const handlers = [];
|
||||
|
||||
if (!jQuery) {
|
||||
if (checkOnly) {
|
||||
return false;
|
||||
}
|
||||
return handlers;
|
||||
}
|
||||
|
||||
let eventsObj = null;
|
||||
|
||||
const data = jQuery._data || jQuery.data;
|
||||
if (data) {
|
||||
// jQuery 1.2+
|
||||
eventsObj = data(node, "events");
|
||||
} else {
|
||||
// JQuery 1.0 & 1.1
|
||||
const entry = jQuery(node)[0];
|
||||
|
||||
if (!entry || !entry.events) {
|
||||
if (checkOnly) {
|
||||
return false;
|
||||
}
|
||||
return handlers;
|
||||
}
|
||||
|
||||
eventsObj = entry.events;
|
||||
}
|
||||
|
||||
if (eventsObj) {
|
||||
for (const [type, events] of Object.entries(eventsObj)) {
|
||||
for (const [, event] of Object.entries(events)) {
|
||||
// Skip events that are part of jQueries internals.
|
||||
if (node.nodeType == node.DOCUMENT_NODE && event.selector) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (typeof event === "function" || typeof event === "object") {
|
||||
if (checkOnly) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const eventInfo = {
|
||||
type: type,
|
||||
handler: event.handler || event,
|
||||
tags: "jQuery",
|
||||
hide: {
|
||||
capturing: true,
|
||||
dom0: true,
|
||||
},
|
||||
};
|
||||
|
||||
handlers.push(eventInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (checkOnly) {
|
||||
return false;
|
||||
}
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or detect jQuery live events.
|
||||
*/
|
||||
class JQueryLiveEventCollector extends MainEventCollector {
|
||||
getListeners(node, {checkOnly} = {}) {
|
||||
const jQuery = this.getJQuery(node);
|
||||
const handlers = [];
|
||||
|
||||
if (!jQuery) {
|
||||
if (checkOnly) {
|
||||
return false;
|
||||
}
|
||||
return handlers;
|
||||
}
|
||||
|
||||
const data = jQuery._data || jQuery.data;
|
||||
|
||||
if (data) {
|
||||
// Live events are added to the document and bubble up to all elements.
|
||||
// Any element matching the specified selector will trigger the live
|
||||
// event.
|
||||
const win = this.unwrap(node.ownerGlobal);
|
||||
const events = data(win.document, "events");
|
||||
|
||||
if (events) {
|
||||
for (const [, eventHolder] of Object.entries(events)) {
|
||||
for (const [idx, event] of Object.entries(eventHolder)) {
|
||||
if (typeof idx !== "string" || isNaN(parseInt(idx, 10))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let selector = event.selector;
|
||||
|
||||
if (!selector && event.data) {
|
||||
selector = event.data.selector || event.data || event.selector;
|
||||
}
|
||||
|
||||
if (!selector || !node.ownerDocument) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let matches;
|
||||
try {
|
||||
matches = node.matches && node.matches(selector);
|
||||
} catch (e) {
|
||||
// Invalid selector, do nothing.
|
||||
}
|
||||
|
||||
if (!matches) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (typeof event === "function" || typeof event === "object") {
|
||||
if (checkOnly) {
|
||||
return true;
|
||||
}
|
||||
const eventInfo = {
|
||||
type: event.origType || event.type.substr(selector.length + 1),
|
||||
handler: event.handler || event,
|
||||
tags: "jQuery,Live",
|
||||
hide: {
|
||||
dom0: true,
|
||||
capturing: true,
|
||||
},
|
||||
};
|
||||
|
||||
if (!eventInfo.type && event.data && event.data.live) {
|
||||
eventInfo.type = event.data.live;
|
||||
}
|
||||
|
||||
handlers.push(eventInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (checkOnly) {
|
||||
return false;
|
||||
}
|
||||
return handlers;
|
||||
}
|
||||
|
||||
normalizeListener(handlerDO) {
|
||||
function isFunctionInProxy(funcDO) {
|
||||
// If the anonymous function is inside the |proxy| function and the
|
||||
// function only has guessed atom, the guessed atom should starts with
|
||||
// "proxy/".
|
||||
const displayName = funcDO.displayName;
|
||||
if (displayName && displayName.startsWith("proxy/")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the anonymous function is inside the |proxy| function and the
|
||||
// function gets name at compile time by SetFunctionName, its guessed
|
||||
// atom doesn't contain "proxy/". In that case, check if the caller is
|
||||
// "proxy" function, as a fallback.
|
||||
const calleeDO = funcDO.environment.callee;
|
||||
if (!calleeDO) {
|
||||
return false;
|
||||
}
|
||||
const calleeName = calleeDO.displayName;
|
||||
return calleeName == "proxy";
|
||||
}
|
||||
|
||||
function getFirstFunctionVariable(funcDO) {
|
||||
// The handler function inside the |proxy| function should point the
|
||||
// unwrapped function via environment variable.
|
||||
const names = funcDO.environment.names();
|
||||
for (const varName of names) {
|
||||
const varDO = handlerDO.environment.getVariable(varName);
|
||||
if (!varDO) {
|
||||
continue;
|
||||
}
|
||||
if (varDO.class == "Function") {
|
||||
return varDO;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!isFunctionInProxy(handlerDO)) {
|
||||
return handlerDO;
|
||||
}
|
||||
|
||||
const MAX_NESTED_HANDLER_COUNT = 2;
|
||||
for (let i = 0; i < MAX_NESTED_HANDLER_COUNT; i++) {
|
||||
const funcDO = getFirstFunctionVariable(handlerDO);
|
||||
if (!funcDO) {
|
||||
return handlerDO;
|
||||
}
|
||||
|
||||
handlerDO = funcDO;
|
||||
if (isFunctionInProxy(handlerDO)) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return handlerDO;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or detect React events.
|
||||
*/
|
||||
class ReactEventCollector extends MainEventCollector {
|
||||
getListeners(node, {checkOnly} = {}) {
|
||||
const handlers = [];
|
||||
const props = this.getProps(node);
|
||||
|
||||
if (props) {
|
||||
for (const [name, prop] of Object.entries(props)) {
|
||||
if (REACT_EVENT_NAMES.includes(name)) {
|
||||
const listener = prop.__reactBoundMethod || prop;
|
||||
|
||||
if (typeof listener !== "function") {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (checkOnly) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const handler = {
|
||||
type: name,
|
||||
handler: listener,
|
||||
tags: "React",
|
||||
hide: {
|
||||
dom0: true,
|
||||
},
|
||||
override: {
|
||||
capturing: name.endsWith("Capture"),
|
||||
},
|
||||
};
|
||||
|
||||
handlers.push(handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (checkOnly) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return handlers;
|
||||
}
|
||||
|
||||
getProps(node) {
|
||||
node = this.unwrap(node);
|
||||
|
||||
for (const key of Object.keys(node)) {
|
||||
if (key.startsWith("__reactInternalInstance$")) {
|
||||
const value = node[key];
|
||||
if (value.memoizedProps) {
|
||||
return value.memoizedProps; // React 16
|
||||
}
|
||||
return value._currentElement.props; // React 15
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
normalizeListener(handlerDO, listener) {
|
||||
let functionText = "";
|
||||
|
||||
if (handlerDO.boundTargetFunction) {
|
||||
handlerDO = handlerDO.boundTargetFunction;
|
||||
}
|
||||
|
||||
const introScript = handlerDO.script.source.introductionScript;
|
||||
const script = handlerDO.script;
|
||||
|
||||
// If this is a Babel transpiled function we have no access to the
|
||||
// source location so we need to hide the filename and debugger
|
||||
// icon.
|
||||
if (introScript && introScript.displayName.endsWith("/transform.run")) {
|
||||
listener.hide.debugger = true;
|
||||
listener.hide.filename = true;
|
||||
|
||||
if (!handlerDO.isArrowFunction) {
|
||||
functionText += "function (";
|
||||
} else {
|
||||
functionText += "(";
|
||||
}
|
||||
|
||||
functionText += handlerDO.parameterNames.join(", ");
|
||||
|
||||
functionText += ") {\n";
|
||||
|
||||
const scriptSource = script.source.text;
|
||||
functionText +=
|
||||
scriptSource.substr(script.sourceStart, script.sourceLength);
|
||||
|
||||
listener.override.handler = functionText;
|
||||
}
|
||||
|
||||
return handlerDO;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The exposed class responsible for gathering events.
|
||||
*/
|
||||
class EventCollector {
|
||||
constructor() {
|
||||
// The event collector array. Please preserve the order otherwise there will
|
||||
// be multiple failing tests.
|
||||
this.eventCollectors = [
|
||||
new ReactEventCollector(),
|
||||
new JQueryLiveEventCollector(),
|
||||
new JQueryEventCollector(),
|
||||
new DOMEventCollector(),
|
||||
];
|
||||
|
||||
// Add a method to create a simple debugger.
|
||||
this.makeDebuggerForContent = makeDebugger.bind(null, {
|
||||
findDebuggees: dbg => [],
|
||||
shouldAddNewGlobalAsDebuggee: global => true,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor (must be called manually).
|
||||
*/
|
||||
destroy() {
|
||||
this.eventCollectors = null;
|
||||
this.makeDebuggerForContent = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterate through all event collectors returning on the first found event.
|
||||
*
|
||||
* @param {DOMNode} node
|
||||
* The node to be checked for events.
|
||||
* @return {Boolean}
|
||||
* True if the node has event listeners, false otherwise.
|
||||
*/
|
||||
hasEventListeners(node) {
|
||||
for (const collector of this.eventCollectors) {
|
||||
if (collector.hasListeners(node)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {DOMNode} node
|
||||
* The node for which events are to be gathered.
|
||||
* @return {Array}
|
||||
* An array containing objects in the following format:
|
||||
* {
|
||||
* type: type, // e.g. "click"
|
||||
* handler: handler, // The function called when event is triggered.
|
||||
* tags: "jQuery", // Comma seperated list of tags displayed
|
||||
* // inside event bubble.
|
||||
* hide: { // Flags for hiding certain properties.
|
||||
* capturing: true,
|
||||
* dom0: true,
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
getEventListeners(node) {
|
||||
const listenerArray = [];
|
||||
const dbg = this.makeDebuggerForContent();
|
||||
const global = Cu.getGlobalForObject(node);
|
||||
const globalDO = dbg.addDebuggee(global);
|
||||
|
||||
for (const collector of this.eventCollectors) {
|
||||
const listeners = collector.getListeners(node);
|
||||
|
||||
if (!listeners) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const listener of listeners) {
|
||||
if (collector.normalizeListener) {
|
||||
listener.normalizeListener = collector.normalizeListener;
|
||||
}
|
||||
this.processHandlerForEvent(listenerArray, listener, globalDO);
|
||||
}
|
||||
}
|
||||
|
||||
dbg.removeDebuggee(globalDO);
|
||||
|
||||
listenerArray.sort((a, b) => {
|
||||
return a.type.localeCompare(b.type);
|
||||
});
|
||||
|
||||
return listenerArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process an event listener.
|
||||
*
|
||||
* @param {Array} listenerArray
|
||||
* listenerArray contains all event objects that we have gathered
|
||||
* so far.
|
||||
* @param {Object} eventInfo
|
||||
* See event-parsers.js.registerEventParser() for a description of the
|
||||
* eventInfo object.
|
||||
*
|
||||
* @return {Array}
|
||||
* An array of objects where a typical object looks like this:
|
||||
* {
|
||||
* type: "click",
|
||||
* handler: function() { doSomething() },
|
||||
* origin: "http://www.mozilla.com",
|
||||
* tags: tags,
|
||||
* DOM0: true,
|
||||
* capturing: true,
|
||||
* hide: {
|
||||
* DOM0: true
|
||||
* },
|
||||
* native: false
|
||||
* }
|
||||
*/
|
||||
processHandlerForEvent(listenerArray, listener, globalDO) {
|
||||
const { capturing, handler } = listener;
|
||||
let listenerDO = globalDO.makeDebuggeeValue(handler);
|
||||
|
||||
const { normalizeListener } = listener;
|
||||
|
||||
if (normalizeListener) {
|
||||
listenerDO = normalizeListener(listenerDO, listener);
|
||||
}
|
||||
|
||||
const hide = listener.hide || {};
|
||||
const override = listener.override || {};
|
||||
const tags = listener.tags || "";
|
||||
const type = listener.type || "";
|
||||
let dom0 = false;
|
||||
let functionSource = handler.toString();
|
||||
let line = 0;
|
||||
let native = false;
|
||||
let url = "";
|
||||
|
||||
// If the listener is an object with a 'handleEvent' method, use that.
|
||||
if (listenerDO.class === "Object" || /^XUL\w*Element$/.test(listenerDO.class)) {
|
||||
let desc;
|
||||
|
||||
while (!desc && listenerDO) {
|
||||
desc = listenerDO.getOwnPropertyDescriptor("handleEvent");
|
||||
listenerDO = listenerDO.proto;
|
||||
}
|
||||
|
||||
if (desc && desc.value) {
|
||||
listenerDO = desc.value;
|
||||
}
|
||||
}
|
||||
|
||||
// If the listener is bound to a different context then we need to switch
|
||||
// to the bound function.
|
||||
if (listenerDO.isBoundFunction) {
|
||||
listenerDO = listenerDO.boundTargetFunction;
|
||||
}
|
||||
|
||||
const { isArrowFunction, name, script, parameterNames } = listenerDO;
|
||||
|
||||
if (script) {
|
||||
const scriptSource = script.source.text;
|
||||
|
||||
// Scripts are provided via script tags. If it wasn't provided by a
|
||||
// script tag it must be a DOM0 event.
|
||||
if (script.source.element) {
|
||||
dom0 = script.source.element.class !== "HTMLScriptElement";
|
||||
} else {
|
||||
dom0 = false;
|
||||
}
|
||||
|
||||
line = script.startLine;
|
||||
url = script.url;
|
||||
|
||||
// Checking for the string "[native code]" is the only way at this point
|
||||
// to check for native code. Even if this provides a false positive then
|
||||
// grabbing the source code a second time is harmless.
|
||||
if (functionSource === "[object Object]" ||
|
||||
functionSource === "[object XULElement]" ||
|
||||
functionSource.includes("[native code]")) {
|
||||
functionSource =
|
||||
scriptSource.substr(script.sourceStart, script.sourceLength);
|
||||
|
||||
// At this point the script looks like this:
|
||||
// () { ... }
|
||||
// We prefix this with "function" if it is not a fat arrow function.
|
||||
if (!isArrowFunction) {
|
||||
functionSource = "function " + functionSource;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// If the listener is a native one (provided by C++ code) then we have no
|
||||
// access to the script. We use the native flag to prevent showing the
|
||||
// debugger button because the script is not available.
|
||||
native = true;
|
||||
}
|
||||
|
||||
// Arrow function text always contains the parameters. Function
|
||||
// parameters are often missing e.g. if Array.sort is used as a handler.
|
||||
// If they are missing we provide the parameters ourselves.
|
||||
if (parameterNames && parameterNames.length > 0) {
|
||||
const prefix = "function " + name + "()";
|
||||
const paramString = parameterNames.join(", ");
|
||||
|
||||
if (functionSource.startsWith(prefix)) {
|
||||
functionSource = functionSource.substr(prefix.length);
|
||||
|
||||
functionSource = `function ${name} (${paramString})${functionSource}`;
|
||||
}
|
||||
}
|
||||
|
||||
// If the listener is native code we display the filename "[native code]."
|
||||
// This is the official string and should *not* be translated.
|
||||
let origin;
|
||||
if (native) {
|
||||
origin = "[native code]";
|
||||
} else {
|
||||
origin = url + ((dom0 || line === 0) ? "" : ":" + line);
|
||||
}
|
||||
|
||||
const eventObj = {
|
||||
type: override.type || type,
|
||||
handler: override.handler || functionSource.trim(),
|
||||
origin: override.origin || origin,
|
||||
tags: override.tags || tags,
|
||||
DOM0: typeof override.dom0 !== "undefined" ? override.dom0 : dom0,
|
||||
capturing: typeof override.capturing !== "undefined" ?
|
||||
override.capturing : capturing,
|
||||
hide: typeof override.hide !== "undefined" ? override.hide : hide,
|
||||
native,
|
||||
};
|
||||
|
||||
// Hide the debugger icon for DOM0 and native listeners. DOM0 listeners are
|
||||
// generated dynamically from e.g. an onclick="" attribute so the script
|
||||
// doesn't actually exist.
|
||||
if (native || dom0) {
|
||||
eventObj.hide.debugger = true;
|
||||
}
|
||||
|
||||
listenerArray.push(eventObj);
|
||||
}
|
||||
}
|
||||
|
||||
exports.EventCollector = EventCollector;
|
|
@ -1,623 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// This file contains event parsers that are then used by developer tools in
|
||||
// order to find information about events affecting an HTML element.
|
||||
|
||||
"use strict";
|
||||
|
||||
const { Cu } = require("chrome");
|
||||
const Services = require("Services");
|
||||
|
||||
// eslint-disable-next-line
|
||||
const JQUERY_LIVE_REGEX = /return typeof \w+.*.event\.triggered[\s\S]*\.event\.(dispatch|handle).*arguments/;
|
||||
|
||||
var parsers = [
|
||||
{
|
||||
id: "jQuery events",
|
||||
hasListeners: function(node) {
|
||||
const global = node.ownerGlobal.wrappedJSObject;
|
||||
const hasJQuery = global.jQuery && global.jQuery.fn && global.jQuery.fn.jquery;
|
||||
|
||||
if (!hasJQuery) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const jQuery = global.jQuery;
|
||||
const handlers = [];
|
||||
|
||||
// jQuery 1.2+
|
||||
const data = jQuery._data || jQuery.data;
|
||||
if (data) {
|
||||
const eventsObj = data(node, "events");
|
||||
for (const type in eventsObj) {
|
||||
const events = eventsObj[type];
|
||||
for (const key in events) {
|
||||
const event = events[key];
|
||||
|
||||
if (node.wrappedJSObject == global.document && event.selector) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (typeof event === "object" || typeof event === "function") {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// JQuery 1.0 & 1.1
|
||||
const entry = jQuery(node)[0];
|
||||
if (!entry) {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
for (const type in entry.events) {
|
||||
const events = entry.events[type];
|
||||
for (const key in events) {
|
||||
const event = events[key];
|
||||
|
||||
if (node.wrappedJSObject == global.document && event.selector) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (typeof events[key] === "function") {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
getListeners: function(node) {
|
||||
const global = node.ownerGlobal.wrappedJSObject;
|
||||
const hasJQuery = global.jQuery && global.jQuery.fn && global.jQuery.fn.jquery;
|
||||
|
||||
if (!hasJQuery) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const jQuery = global.jQuery;
|
||||
const handlers = [];
|
||||
|
||||
// jQuery 1.2+
|
||||
const data = jQuery._data || jQuery.data;
|
||||
if (data) {
|
||||
const eventsObj = data(node, "events");
|
||||
for (const type in eventsObj) {
|
||||
const events = eventsObj[type];
|
||||
for (const key in events) {
|
||||
const event = events[key];
|
||||
|
||||
if (node.wrappedJSObject == global.document && event.selector) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (typeof event === "object" || typeof event === "function") {
|
||||
const eventInfo = {
|
||||
type: type,
|
||||
handler: event.handler || event,
|
||||
tags: "jQuery",
|
||||
hide: {
|
||||
capturing: true,
|
||||
dom0: true,
|
||||
},
|
||||
};
|
||||
|
||||
handlers.push(eventInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// JQuery 1.0 & 1.1
|
||||
const entry = jQuery(node)[0];
|
||||
|
||||
if (!entry) {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
for (const type in entry.events) {
|
||||
const events = entry.events[type];
|
||||
for (const key in events) {
|
||||
const event = events[key];
|
||||
|
||||
if (node.wrappedJSObject == global.document && event.selector) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (typeof events[key] === "function") {
|
||||
const eventInfo = {
|
||||
type: type,
|
||||
handler: events[key],
|
||||
tags: "jQuery",
|
||||
hide: {
|
||||
capturing: true,
|
||||
dom0: true,
|
||||
},
|
||||
};
|
||||
|
||||
handlers.push(eventInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return handlers;
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "jQuery live events",
|
||||
hasListeners: function(node) {
|
||||
return jQueryLiveGetListeners(node, true);
|
||||
},
|
||||
getListeners: function(node) {
|
||||
return jQueryLiveGetListeners(node, false);
|
||||
},
|
||||
normalizeListener: function(handlerDO) {
|
||||
function isFunctionInProxy(funcDO) {
|
||||
// If the anonymous function is inside the |proxy| function and the
|
||||
// function only has guessed atom, the guessed atom should starts with
|
||||
// "proxy/".
|
||||
const displayName = funcDO.displayName;
|
||||
if (displayName && displayName.startsWith("proxy/")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the anonymous function is inside the |proxy| function and the
|
||||
// function gets name at compile time by SetFunctionName, its guessed
|
||||
// atom doesn't contain "proxy/". In that case, check if the caller is
|
||||
// "proxy" function, as a fallback.
|
||||
const calleeDO = funcDO.environment.callee;
|
||||
if (!calleeDO) {
|
||||
return false;
|
||||
}
|
||||
const calleeName = calleeDO.displayName;
|
||||
return calleeName == "proxy";
|
||||
}
|
||||
|
||||
function getFirstFunctionVariable(funcDO) {
|
||||
// The handler function inside the |proxy| function should point the
|
||||
// unwrapped function via environment variable.
|
||||
const names = funcDO.environment.names();
|
||||
for (const varName of names) {
|
||||
const varDO = handlerDO.environment.getVariable(varName);
|
||||
if (!varDO) {
|
||||
continue;
|
||||
}
|
||||
if (varDO.class == "Function") {
|
||||
return varDO;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!isFunctionInProxy(handlerDO)) {
|
||||
return handlerDO;
|
||||
}
|
||||
|
||||
const MAX_NESTED_HANDLER_COUNT = 2;
|
||||
for (let i = 0; i < MAX_NESTED_HANDLER_COUNT; i++) {
|
||||
const funcDO = getFirstFunctionVariable(handlerDO);
|
||||
if (!funcDO) {
|
||||
return handlerDO;
|
||||
}
|
||||
|
||||
handlerDO = funcDO;
|
||||
if (isFunctionInProxy(handlerDO)) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return handlerDO;
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "DOM events",
|
||||
hasListeners: function(node) {
|
||||
let listeners;
|
||||
|
||||
if (node.nodeName.toLowerCase() === "html") {
|
||||
const winListeners =
|
||||
Services.els.getListenerInfoFor(node.ownerGlobal) || [];
|
||||
const docElementListeners =
|
||||
Services.els.getListenerInfoFor(node) || [];
|
||||
const docListeners =
|
||||
Services.els.getListenerInfoFor(node.parentNode) || [];
|
||||
|
||||
listeners = [...winListeners, ...docElementListeners, ...docListeners];
|
||||
} else {
|
||||
listeners = Services.els.getListenerInfoFor(node) || [];
|
||||
}
|
||||
|
||||
for (const listener of listeners) {
|
||||
if (isValidDOMListener(listener)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
getListeners: function(node) {
|
||||
const handlers = [];
|
||||
const listeners = Services.els.getListenerInfoFor(node);
|
||||
|
||||
// The Node actor's getEventListenerInfo knows that when an html tag has
|
||||
// been passed we need the window object so we don't need to account for
|
||||
// event hoisting here as we did in hasListeners.
|
||||
|
||||
for (const listener of listeners) {
|
||||
if (!isValidDOMListener(listener)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get the listener object, either a Function or an Object.
|
||||
let obj = listener.listenerObject;
|
||||
|
||||
// Unwrap the listener in order to see content objects.
|
||||
if (Cu.isXrayWrapper(obj)) {
|
||||
obj = listener.listenerObject.wrappedJSObject;
|
||||
}
|
||||
|
||||
let handler = null;
|
||||
|
||||
// An object without a valid handleEvent is not a valid listener.
|
||||
if (typeof obj === "object") {
|
||||
const unwrapped = Cu.isXrayWrapper(obj) ? obj.wrappedJSObject : obj;
|
||||
if (typeof unwrapped.handleEvent === "function") {
|
||||
handler = Cu.unwaiveXrays(unwrapped.handleEvent);
|
||||
}
|
||||
} else if (typeof obj === "function") {
|
||||
// Ignore DOM events used to trigger jQuery events as they are only
|
||||
// useful to the developers of the jQuery library.
|
||||
if (JQUERY_LIVE_REGEX.test(obj.toString())) {
|
||||
continue;
|
||||
}
|
||||
// Otherwise, the other valid listener type is function.
|
||||
handler = obj;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
const eventInfo = {
|
||||
capturing: listener.capturing,
|
||||
type: listener.type,
|
||||
handler: handler,
|
||||
};
|
||||
|
||||
handlers.push(eventInfo);
|
||||
}
|
||||
|
||||
return handlers;
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "React events",
|
||||
hasListeners: function(node) {
|
||||
return reactGetListeners(node, true);
|
||||
},
|
||||
|
||||
getListeners: function(node) {
|
||||
return reactGetListeners(node, false);
|
||||
},
|
||||
|
||||
normalizeListener: function(handlerDO, listener) {
|
||||
let functionText = "";
|
||||
|
||||
if (handlerDO.boundTargetFunction) {
|
||||
handlerDO = handlerDO.boundTargetFunction;
|
||||
}
|
||||
|
||||
const introScript = handlerDO.script.source.introductionScript;
|
||||
const script = handlerDO.script;
|
||||
|
||||
// If this is a Babel transpiled function we have no access to the
|
||||
// source location so we need to hide the filename and debugger
|
||||
// icon.
|
||||
if (introScript && introScript.displayName.endsWith("/transform.run")) {
|
||||
listener.hide.debugger = true;
|
||||
listener.hide.filename = true;
|
||||
|
||||
if (!handlerDO.isArrowFunction) {
|
||||
functionText += "function (";
|
||||
} else {
|
||||
functionText += "(";
|
||||
}
|
||||
|
||||
functionText += handlerDO.parameterNames.join(", ");
|
||||
|
||||
functionText += ") {\n";
|
||||
|
||||
const scriptSource = script.source.text;
|
||||
functionText +=
|
||||
scriptSource.substr(script.sourceStart, script.sourceLength);
|
||||
|
||||
listener.override.handler = functionText;
|
||||
}
|
||||
|
||||
return handlerDO;
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
function reactGetListeners(node, boolOnEventFound) {
|
||||
function getProps() {
|
||||
for (const key of Object.keys(node)) {
|
||||
if (key.startsWith("__reactInternalInstance$")) {
|
||||
const value = node[key];
|
||||
if (value.memoizedProps) {
|
||||
return value.memoizedProps; // React 16
|
||||
}
|
||||
return value._currentElement.props; // React 15
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
node = node.wrappedJSObject || node;
|
||||
|
||||
const handlers = [];
|
||||
const props = getProps();
|
||||
|
||||
if (props) {
|
||||
for (const name in props) {
|
||||
if (name.startsWith("on")) {
|
||||
const prop = props[name];
|
||||
const listener = prop.__reactBoundMethod || prop;
|
||||
|
||||
if (typeof listener !== "function") {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (boolOnEventFound) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const handler = {
|
||||
type: name,
|
||||
handler: listener,
|
||||
tags: "React",
|
||||
hide: {
|
||||
dom0: true,
|
||||
},
|
||||
override: {
|
||||
capturing: name.endsWith("Capture"),
|
||||
},
|
||||
};
|
||||
|
||||
handlers.push(handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (boolOnEventFound) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return handlers;
|
||||
}
|
||||
|
||||
function jQueryLiveGetListeners(node, boolOnEventFound) {
|
||||
const global = node.ownerGlobal.wrappedJSObject;
|
||||
const hasJQuery = global.jQuery && global.jQuery.fn && global.jQuery.fn.jquery;
|
||||
|
||||
if (!hasJQuery) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const jQuery = global.jQuery;
|
||||
const handlers = [];
|
||||
const data = jQuery._data || jQuery.data;
|
||||
|
||||
if (data) {
|
||||
// Live events are added to the document and bubble up to all elements.
|
||||
// Any element matching the specified selector will trigger the live
|
||||
// event.
|
||||
const events = data(global.document, "events");
|
||||
|
||||
for (const type in events) {
|
||||
const eventHolder = events[type];
|
||||
|
||||
for (const idx in eventHolder) {
|
||||
if (typeof idx !== "string" || isNaN(parseInt(idx, 10))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const event = eventHolder[idx];
|
||||
let selector = event.selector;
|
||||
|
||||
if (!selector && event.data) {
|
||||
selector = event.data.selector || event.data || event.selector;
|
||||
}
|
||||
|
||||
if (!selector || !node.ownerDocument) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let matches;
|
||||
try {
|
||||
matches = node.matches && node.matches(selector);
|
||||
} catch (e) {
|
||||
// Invalid selector, do nothing.
|
||||
}
|
||||
|
||||
if (boolOnEventFound && matches) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!matches) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!boolOnEventFound &&
|
||||
(typeof event === "object" || typeof event === "function")) {
|
||||
const eventInfo = {
|
||||
type: event.origType || event.type.substr(selector.length + 1),
|
||||
handler: event.handler || event,
|
||||
tags: "jQuery,Live",
|
||||
hide: {
|
||||
dom0: true,
|
||||
capturing: true,
|
||||
},
|
||||
};
|
||||
|
||||
if (!eventInfo.type && event.data && event.data.live) {
|
||||
eventInfo.type = event.data.live;
|
||||
}
|
||||
|
||||
handlers.push(eventInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (boolOnEventFound) {
|
||||
return false;
|
||||
}
|
||||
return handlers;
|
||||
}
|
||||
|
||||
function isValidDOMListener(listener) {
|
||||
// Ignore listeners without a type, e.g.
|
||||
// node.addEventListener("", function() {})
|
||||
if (!listener.type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the listener object, either a Function or an Object.
|
||||
let obj = listener.listenerObject;
|
||||
|
||||
// Ignore listeners without any listener, e.g.
|
||||
// node.addEventListener("mouseover", null);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Unwrap the listener in order to see content objects.
|
||||
if (Cu.isXrayWrapper(obj)) {
|
||||
obj = listener.listenerObject.wrappedJSObject;
|
||||
}
|
||||
|
||||
// An object without a valid handleEvent is not a valid listener.
|
||||
if (typeof obj === "object") {
|
||||
const unwrapped = Cu.isXrayWrapper(obj) ? obj.wrappedJSObject : obj;
|
||||
if (typeof unwrapped.handleEvent === "function") {
|
||||
return Cu.unwaiveXrays(unwrapped.handleEvent);
|
||||
}
|
||||
return false;
|
||||
} else if (typeof obj === "function") {
|
||||
if (JQUERY_LIVE_REGEX.test(obj.toString())) {
|
||||
return false;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
this.EventParsers = function EventParsers() {
|
||||
if (this._eventParsers.size === 0) {
|
||||
for (const parserObj of parsers) {
|
||||
this.registerEventParser(parserObj);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
exports.EventParsers = EventParsers;
|
||||
|
||||
EventParsers.prototype = {
|
||||
// NOTE: This is shared amongst all instances.
|
||||
_eventParsers: new Map(),
|
||||
|
||||
get parsers() {
|
||||
return this._eventParsers;
|
||||
},
|
||||
|
||||
/**
|
||||
* Register a new event parser to be used in the processing of event info.
|
||||
*
|
||||
* @param {Object} parserObj
|
||||
* Each parser must contain the following properties:
|
||||
* - parser, which must take the following form:
|
||||
* {
|
||||
* id {String}: "jQuery events", // Unique id.
|
||||
* getListeners: function(node) { }, // Function that takes a node
|
||||
* // and returns an array of
|
||||
* // eventInfo objects (see
|
||||
* // below).
|
||||
*
|
||||
* hasListeners: function(node) { }, // Optional function that takes
|
||||
* // a node and returns a boolean
|
||||
* // indicating whether a node has
|
||||
* // listeners attached.
|
||||
*
|
||||
* normalizeListener:
|
||||
* function(fnDO, listener) { }, // Optional function that takes
|
||||
* // a Debugger.Object instance
|
||||
* // and an optional listener
|
||||
* // object. Both objects can be
|
||||
* // manipulated to display the
|
||||
* // correct information in the
|
||||
* // event bubble.
|
||||
* }
|
||||
*
|
||||
* An eventInfo object should take the following form:
|
||||
* {
|
||||
* type {String}: "click",
|
||||
* handler {Function}: event handler,
|
||||
* tags {String}: "jQuery,Live", // These tags will be displayed as
|
||||
* // attributes in the events popup.
|
||||
* hide: { // Hide or show fields:
|
||||
* debugger: false, // Debugger icon
|
||||
* type: false, // Event type e.g. click
|
||||
* filename: false, // Filename
|
||||
* capturing: false, // Capturing
|
||||
* dom0: false // DOM 0
|
||||
* },
|
||||
*
|
||||
* override: { // The following can be overridden:
|
||||
* handler: someEventHandler,
|
||||
* type: "click",
|
||||
* origin: "http://www.mozilla.com",
|
||||
* searchString: 'onclick="doSomething()"',
|
||||
* dom0: true,
|
||||
* capturing: true
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
registerEventParser: function(parserObj) {
|
||||
const parserId = parserObj.id;
|
||||
|
||||
if (!parserId) {
|
||||
throw new Error("Cannot register new event parser with id " + parserId);
|
||||
}
|
||||
if (this._eventParsers.has(parserId)) {
|
||||
throw new Error("Duplicate event parser id " + parserId);
|
||||
}
|
||||
|
||||
this._eventParsers.set(parserId, {
|
||||
getListeners: parserObj.getListeners,
|
||||
hasListeners: parserObj.hasListeners,
|
||||
normalizeListener: parserObj.normalizeListener,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes parser that matches a given parserId.
|
||||
*
|
||||
* @param {String} parserId
|
||||
* id of the event parser to unregister.
|
||||
*/
|
||||
unregisterEventParser: function(parserId) {
|
||||
this._eventParsers.delete(parserId);
|
||||
},
|
||||
|
||||
/**
|
||||
* Tidy up parsers.
|
||||
*/
|
||||
destroy: function() {
|
||||
for (const [id] of this._eventParsers) {
|
||||
this.unregisterEventParser(id, true);
|
||||
}
|
||||
},
|
||||
};
|
|
@ -8,7 +8,7 @@ DevToolsModules(
|
|||
'css-logic.js',
|
||||
'custom-element-watcher.js',
|
||||
'document-walker.js',
|
||||
'event-parsers.js',
|
||||
'event-collector.js',
|
||||
'inspector.js',
|
||||
'node.js',
|
||||
'utils.js',
|
||||
|
|
|
@ -29,7 +29,7 @@ loader.lazyRequireGetter(this, "InspectorActorUtils", "devtools/server/actors/in
|
|||
loader.lazyRequireGetter(this, "LongStringActor", "devtools/server/actors/string", true);
|
||||
loader.lazyRequireGetter(this, "getFontPreviewData", "devtools/server/actors/styles", true);
|
||||
loader.lazyRequireGetter(this, "CssLogic", "devtools/server/actors/inspector/css-logic", true);
|
||||
loader.lazyRequireGetter(this, "EventParsers", "devtools/server/actors/inspector/event-parsers", true);
|
||||
loader.lazyRequireGetter(this, "EventCollector", "devtools/server/actors/inspector/event-collector", true);
|
||||
loader.lazyRequireGetter(this, "DocumentWalker", "devtools/server/actors/inspector/document-walker", true);
|
||||
loader.lazyRequireGetter(this, "scrollbarTreeWalkerFilter", "devtools/server/actors/inspector/utils", true);
|
||||
|
||||
|
@ -48,7 +48,7 @@ const NodeActor = protocol.ActorClassWithSpec(nodeSpec, {
|
|||
protocol.Actor.prototype.initialize.call(this, null);
|
||||
this.walker = walker;
|
||||
this.rawNode = node;
|
||||
this._eventParsers = new EventParsers().parsers;
|
||||
this._eventCollector = new EventCollector();
|
||||
|
||||
// Store the original display type and scrollable state and whether or not the node is
|
||||
// displayed to track changes when reflows occur.
|
||||
|
@ -92,6 +92,8 @@ const NodeActor = protocol.ActorClassWithSpec(nodeSpec, {
|
|||
this.slotchangeListener = null;
|
||||
}
|
||||
|
||||
this._eventCollector.destroy();
|
||||
this._eventCollector = null;
|
||||
this.rawNode = null;
|
||||
this.walker = null;
|
||||
},
|
||||
|
@ -287,18 +289,7 @@ const NodeActor = protocol.ActorClassWithSpec(nodeSpec, {
|
|||
* check if there are any event listeners.
|
||||
*/
|
||||
get _hasEventListeners() {
|
||||
const parsers = this._eventParsers;
|
||||
for (const [, {hasListeners}] of parsers) {
|
||||
try {
|
||||
if (hasListeners && hasListeners(this.rawNode)) {
|
||||
return true;
|
||||
}
|
||||
} catch (e) {
|
||||
// An object attached to the node looked like a listener but wasn't...
|
||||
// do nothing.
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return this._eventCollector.hasEventListeners(this.rawNode);
|
||||
},
|
||||
|
||||
writeAttrs: function() {
|
||||
|
@ -332,36 +323,7 @@ const NodeActor = protocol.ActorClassWithSpec(nodeSpec, {
|
|||
* Node for which we are to get listeners.
|
||||
*/
|
||||
getEventListeners: function(node) {
|
||||
const parsers = this._eventParsers;
|
||||
const dbg = this.parent().targetActor.makeDebugger();
|
||||
const listenerArray = [];
|
||||
|
||||
for (const [, {getListeners, normalizeListener}] of parsers) {
|
||||
try {
|
||||
const listeners = getListeners(node);
|
||||
|
||||
if (!listeners) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const listener of listeners) {
|
||||
if (normalizeListener) {
|
||||
listener.normalizeListener = normalizeListener;
|
||||
}
|
||||
|
||||
this.processHandlerForEvent(node, listenerArray, dbg, listener);
|
||||
}
|
||||
} catch (e) {
|
||||
// An object attached to the node looked like a listener but wasn't...
|
||||
// do nothing.
|
||||
}
|
||||
}
|
||||
|
||||
listenerArray.sort((a, b) => {
|
||||
return a.type.localeCompare(b.type);
|
||||
});
|
||||
|
||||
return listenerArray;
|
||||
return this._eventCollector.getEventListeners(node);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -394,165 +356,6 @@ const NodeActor = protocol.ActorClassWithSpec(nodeSpec, {
|
|||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Process a handler
|
||||
*
|
||||
* @param {Node} node
|
||||
* The node for which we want information.
|
||||
* @param {Array} listenerArray
|
||||
* listenerArray contains all event objects that we have gathered
|
||||
* so far.
|
||||
* @param {Debugger} dbg
|
||||
* JSDebugger instance.
|
||||
* @param {Object} eventInfo
|
||||
* See event-parsers.js.registerEventParser() for a description of the
|
||||
* eventInfo object.
|
||||
*
|
||||
* @return {Array}
|
||||
* An array of objects where a typical object looks like this:
|
||||
* {
|
||||
* type: "click",
|
||||
* handler: function() { doSomething() },
|
||||
* origin: "http://www.mozilla.com",
|
||||
* searchString: 'onclick="doSomething()"',
|
||||
* tags: tags,
|
||||
* DOM0: true,
|
||||
* capturing: true,
|
||||
* hide: {
|
||||
* DOM0: true
|
||||
* },
|
||||
* native: false
|
||||
* }
|
||||
*/
|
||||
processHandlerForEvent: function(node, listenerArray, dbg, listener) {
|
||||
const { handler } = listener;
|
||||
const global = Cu.getGlobalForObject(handler);
|
||||
const globalDO = dbg.addDebuggee(global);
|
||||
let listenerDO = globalDO.makeDebuggeeValue(handler);
|
||||
|
||||
const { normalizeListener } = listener;
|
||||
|
||||
if (normalizeListener) {
|
||||
listenerDO = normalizeListener(listenerDO, listener);
|
||||
}
|
||||
|
||||
const { capturing } = listener;
|
||||
let dom0 = false;
|
||||
let functionSource = handler.toString();
|
||||
const hide = listener.hide || {};
|
||||
let line = 0;
|
||||
let native = false;
|
||||
const override = listener.override || {};
|
||||
const tags = listener.tags || "";
|
||||
const type = listener.type || "";
|
||||
let url = "";
|
||||
|
||||
// If the listener is an object with a 'handleEvent' method, use that.
|
||||
if (listenerDO.class === "Object" || /^XUL\w*Element$/.test(listenerDO.class)) {
|
||||
let desc;
|
||||
|
||||
while (!desc && listenerDO) {
|
||||
desc = listenerDO.getOwnPropertyDescriptor("handleEvent");
|
||||
listenerDO = listenerDO.proto;
|
||||
}
|
||||
|
||||
if (desc && desc.value) {
|
||||
listenerDO = desc.value;
|
||||
}
|
||||
}
|
||||
|
||||
// If the listener is bound to a different context then we need to switch
|
||||
// to the bound function.
|
||||
if (listenerDO.isBoundFunction) {
|
||||
listenerDO = listenerDO.boundTargetFunction;
|
||||
}
|
||||
|
||||
const { isArrowFunction, name, script, parameterNames } = listenerDO;
|
||||
|
||||
if (script) {
|
||||
const scriptSource = script.source.text;
|
||||
|
||||
// Scripts are provided via script tags. If it wasn't provided by a
|
||||
// script tag it must be a DOM0 event.
|
||||
if (script.source.element) {
|
||||
dom0 = script.source.element.class !== "HTMLScriptElement";
|
||||
} else {
|
||||
dom0 = false;
|
||||
}
|
||||
|
||||
line = script.startLine;
|
||||
url = script.url;
|
||||
|
||||
// Checking for the string "[native code]" is the only way at this point
|
||||
// to check for native code. Even if this provides a false positive then
|
||||
// grabbing the source code a second time is harmless.
|
||||
if (functionSource === "[object Object]" ||
|
||||
functionSource === "[object XULElement]" ||
|
||||
functionSource.includes("[native code]")) {
|
||||
functionSource =
|
||||
scriptSource.substr(script.sourceStart, script.sourceLength);
|
||||
|
||||
// At this point the script looks like this:
|
||||
// () { ... }
|
||||
// We prefix this with "function" if it is not a fat arrow function.
|
||||
if (!isArrowFunction) {
|
||||
functionSource = "function " + functionSource;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// If the listener is a native one (provided by C++ code) then we have no
|
||||
// access to the script. We use the native flag to prevent showing the
|
||||
// debugger button because the script is not available.
|
||||
native = true;
|
||||
}
|
||||
|
||||
// Fat arrow function text always contains the parameters. Function
|
||||
// parameters are often missing e.g. if Array.sort is used as a handler.
|
||||
// If they are missing we provide the parameters ourselves.
|
||||
if (parameterNames && parameterNames.length > 0) {
|
||||
const prefix = "function " + name + "()";
|
||||
const paramString = parameterNames.join(", ");
|
||||
|
||||
if (functionSource.startsWith(prefix)) {
|
||||
functionSource = functionSource.substr(prefix.length);
|
||||
|
||||
functionSource = `function ${name} (${paramString})${functionSource}`;
|
||||
}
|
||||
}
|
||||
|
||||
// If the listener is native code we display the filename "[native code]."
|
||||
// This is the official string and should *not* be translated.
|
||||
let origin;
|
||||
if (native) {
|
||||
origin = "[native code]";
|
||||
} else {
|
||||
origin = url + ((dom0 || line === 0) ? "" : ":" + line);
|
||||
}
|
||||
|
||||
const eventObj = {
|
||||
type: override.type || type,
|
||||
handler: override.handler || functionSource.trim(),
|
||||
origin: override.origin || origin,
|
||||
tags: override.tags || tags,
|
||||
DOM0: typeof override.dom0 !== "undefined" ? override.dom0 : dom0,
|
||||
capturing: typeof override.capturing !== "undefined" ?
|
||||
override.capturing : capturing,
|
||||
hide: typeof override.hide !== "undefined" ? override.hide : hide,
|
||||
native,
|
||||
};
|
||||
|
||||
// Hide the debugger icon for DOM0 and native listeners. DOM0 listeners are
|
||||
// generated dynamically from e.g. an onclick="" attribute so the script
|
||||
// doesn't actually exist.
|
||||
if (native || dom0) {
|
||||
eventObj.hide.debugger = true;
|
||||
}
|
||||
|
||||
listenerArray.push(eventObj);
|
||||
|
||||
dbg.removeDebuggee(globalDO);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a LongStringActor with the node's value.
|
||||
*/
|
||||
|
@ -632,18 +435,7 @@ const NodeActor = protocol.ActorClassWithSpec(nodeSpec, {
|
|||
* Get all event listeners that are listening on this node.
|
||||
*/
|
||||
getEventListenerInfo: function() {
|
||||
const node = this.rawNode;
|
||||
|
||||
if (this.rawNode.nodeName.toLowerCase() === "html") {
|
||||
const winListeners = this.getEventListeners(node.ownerGlobal) || [];
|
||||
const docElementListeners = this.getEventListeners(node) || [];
|
||||
const docListeners = this.getEventListeners(node.parentNode) || [];
|
||||
|
||||
return [...winListeners, ...docElementListeners, ...docListeners].sort((a, b) => {
|
||||
return a.type.localeCompare(b.type);
|
||||
});
|
||||
}
|
||||
return this.getEventListeners(node);
|
||||
return this.getEventListeners(this.rawNode);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче