mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-12-16 16:28:58 +00:00
Merge pull request #1107 from lightpanda-io/mutation_observer_improvement
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
e2e-test / cdp-and-hyperfine-bench (push) Has been cancelled
e2e-test / perf-fmt (push) Has been cancelled
zig-test / zig build dev (push) Has been cancelled
zig-test / browser fetch (push) Has been cancelled
zig-test / zig test (push) Has been cancelled
zig-test / perf-fmt (push) Has been cancelled
nightly build / build-linux-x86_64 (push) Has been cancelled
nightly build / build-linux-aarch64 (push) Has been cancelled
nightly build / build-macos-aarch64 (push) Has been cancelled
nightly build / build-macos-x86_64 (push) Has been cancelled
wpt / web platform tests json output (push) Has been cancelled
wpt / perf-fmt (push) Has been cancelled
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
e2e-test / cdp-and-hyperfine-bench (push) Has been cancelled
e2e-test / perf-fmt (push) Has been cancelled
zig-test / zig build dev (push) Has been cancelled
zig-test / browser fetch (push) Has been cancelled
zig-test / zig test (push) Has been cancelled
zig-test / perf-fmt (push) Has been cancelled
nightly build / build-linux-x86_64 (push) Has been cancelled
nightly build / build-linux-aarch64 (push) Has been cancelled
nightly build / build-macos-aarch64 (push) Has been cancelled
nightly build / build-macos-x86_64 (push) Has been cancelled
wpt / web platform tests json output (push) Has been cancelled
wpt / perf-fmt (push) Has been cancelled
Use correct 'this' on MutationObserver callback
This commit is contained in:
@@ -11,15 +11,19 @@
|
||||
|
||||
var nb = 0;
|
||||
var mrs;
|
||||
new MutationObserver((mu) => {
|
||||
let cb_this1;
|
||||
let mu1 = new MutationObserver(function(mu) {
|
||||
mrs = mu;
|
||||
nb++;
|
||||
}).observe(document.firstElementChild, { attributes: true, attributeOldValue: true });
|
||||
cb_this1 = this;
|
||||
});
|
||||
mu1.observe(document.firstElementChild, { attributes: true, attributeOldValue: true });
|
||||
document.firstElementChild.setAttribute("foo", "bar");
|
||||
document.firstElementChild.firstChild.setAttribute("foo", "bar");
|
||||
|
||||
testing.eventually(() => {
|
||||
testing.expectEqual(1, nb);
|
||||
testing.expectEqual(cb_this1, mu1);
|
||||
testing.expectEqual('attributes', mrs[0].type);
|
||||
testing.expectEqual(document.firstElementChild, mrs[0].target);
|
||||
testing.expectEqual('bar', mrs[0].target.getAttribute('foo'));
|
||||
@@ -30,14 +34,17 @@
|
||||
var nb2 = 0;
|
||||
var mrs2;
|
||||
var node1 = $('#p1').firstChild;
|
||||
new MutationObserver((mu) => {
|
||||
let mu2 = new MutationObserver((mu) => {
|
||||
mrs2 = mu;
|
||||
nb2++;
|
||||
}).observe(node1, { characterData: true, characterDataOldValue: true });
|
||||
cb_this2 = this;
|
||||
})
|
||||
mu2.observe(node1, { characterData: true, characterDataOldValue: true });
|
||||
node1.data = "foo";
|
||||
|
||||
testing.eventually(() => {
|
||||
testing.expectEqual(1, nb2);
|
||||
testing.expectEqual(window, cb_this2);
|
||||
testing.expectEqual('characterData', mrs2[0].type);
|
||||
testing.expectEqual(node1, mrs2[0].target);
|
||||
testing.expectEqual('foo', mrs2[0].target.data);
|
||||
|
||||
Reference in New Issue
Block a user