mirror of
https://github.com/lexmount/moli.git
synced 2026-11-21 00:03:15 +00:00
fix(dom): expose immutable MutationRecord prototype attributes
Keep record values in private slots and expose the nine readonly attributes through branded prototype getters. Preserve snapshot identity across realms, shadow properties, registered native Proxies, and retained records. Create delivery arguments in the callback function's relevant realm so MutationRecord wrappers and arrays use the correct prototypes.
This commit is contained in:
@@ -722,6 +722,8 @@ fn invoke_mutation_deliveries<'s>(
|
||||
if !delivery.callback.is_current(scope) {
|
||||
continue;
|
||||
}
|
||||
// Convert callback arguments in the callback function's Realm, which
|
||||
// can differ from the observer's construction Realm.
|
||||
let callback_context = delivery.callback.relevant_context(scope);
|
||||
let records_array = {
|
||||
let scope = &mut v8::ContextScope::new(scope, callback_context);
|
||||
|
||||
@@ -42,9 +42,9 @@
|
||||
function produce(owner, doc) {
|
||||
const host = doc.createElement('item');
|
||||
const left = doc.createTextNode('left'), right = doc.createTextNode('right');
|
||||
const text = doc.createTextNode('old text\u00e9'), middle = doc.createElement('middle');
|
||||
const text = doc.createTextNode('old text\udfff'), middle = doc.createElement('middle');
|
||||
host.append(left, right, text);
|
||||
host.setAttributeNS('urn:record', 'p:keep', 'old attr\u{1D306}');
|
||||
host.setAttributeNS('urn:record', 'p:keep', 'old attr\ud800');
|
||||
const observer = new owner.MutationObserver(() => {});
|
||||
observer.observe(host, {attributes: true, attributeOldValue: true,
|
||||
characterData: true, characterDataOldValue: true, childList: true, subtree: true});
|
||||
@@ -58,8 +58,8 @@
|
||||
attributeName: null, attributeNamespace: null, oldValue: null};
|
||||
const expected = [
|
||||
{...empty, type: 'attributes', target: host, attributeName: 'keep',
|
||||
attributeNamespace: 'urn:record', oldValue: 'old attr\u{1D306}'},
|
||||
{...empty, type: 'characterData', target: text, oldValue: 'old text\u00e9'},
|
||||
attributeNamespace: 'urn:record', oldValue: 'old attr\ud800'},
|
||||
{...empty, type: 'characterData', target: text, oldValue: 'old text\udfff'},
|
||||
{...empty, type: 'childList', target: host, addedNodes: [middle], previousSibling: left, nextSibling: right},
|
||||
];
|
||||
return {records, expected, host, text, middle};
|
||||
|
||||
Reference in New Issue
Block a user