mirror of
https://github.com/rkd77/elinks.git
synced 2025-02-02 15:09:23 -05:00
[mujs] document.addEventListener fixes and sample html file
This commit is contained in:
parent
4f6a439cbc
commit
5c3ab7781d
@ -915,7 +915,19 @@ mjs_document_addEventListener(js_State *J)
|
|||||||
}
|
}
|
||||||
js_copy(J, 2);
|
js_copy(J, 2);
|
||||||
const char *fun = js_ref(J);
|
const char *fun = js_ref(J);
|
||||||
|
struct el_listener *l;
|
||||||
|
|
||||||
|
foreach(l, doc_private->listeners) {
|
||||||
|
if (strcmp(l->typ, method)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (l->fun == fun) {
|
||||||
|
mem_free(method);
|
||||||
|
js_pushundefined(J);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
struct el_listener *n = (struct el_listener *)mem_calloc(1, sizeof(*n));
|
struct el_listener *n = (struct el_listener *)mem_calloc(1, sizeof(*n));
|
||||||
|
|
||||||
if (!n) {
|
if (!n) {
|
||||||
@ -1003,7 +1015,7 @@ mjs_document_removeEventListener(js_State *J)
|
|||||||
if (exc != DOM_NO_ERR || !typ) {
|
if (exc != DOM_NO_ERR || !typ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
dom_event_target_remove_event_listener(doc, typ, doc_private->listener, false);
|
//dom_event_target_remove_event_listener(doc, typ, doc_private->listener, false);
|
||||||
dom_string_unref(typ);
|
dom_string_unref(typ);
|
||||||
|
|
||||||
js_unref(J, l->fun);
|
js_unref(J, l->fun);
|
||||||
@ -1713,9 +1725,9 @@ document_event_handler(dom_event *event, void *pw)
|
|||||||
}
|
}
|
||||||
// interpreter->heartbeat = add_heartbeat(interpreter);
|
// interpreter->heartbeat = add_heartbeat(interpreter);
|
||||||
|
|
||||||
struct el_listener *l;
|
struct el_listener *l, *next;
|
||||||
|
|
||||||
foreach(l, doc_private->listeners) {
|
foreachsafe(l, next, doc_private->listeners) {
|
||||||
if (strcmp(l->typ, dom_string_data(typ))) {
|
if (strcmp(l->typ, dom_string_data(typ))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
19
test/ecmascript/ready.html
Normal file
19
test/ecmascript/ready.html
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<!--<script src="jquery.js"></script>-->
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="test">A</div>
|
||||||
|
<script>
|
||||||
|
function ff()
|
||||||
|
{
|
||||||
|
document.removeEventListener("DOMContentLoaded", ff);
|
||||||
|
alert('Loaded');
|
||||||
|
}
|
||||||
|
document.addEventListener("DOMContentLoaded", ff);
|
||||||
|
//$(document).ready(function(){
|
||||||
|
// alert('READY');
|
||||||
|
//});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
x
Reference in New Issue
Block a user