Skip to content
This repository has been archived by the owner on Nov 11, 2019. It is now read-only.

add changed value to mutation record #8

Open
andreasplesch opened this issue Nov 18, 2016 · 4 comments
Open

add changed value to mutation record #8

andreasplesch opened this issue Nov 18, 2016 · 4 comments
Labels

Comments

@andreasplesch
Copy link

https://www.w3.org/TR/dom/#interface-mutationrecord

A sequence of mutations observed and recorded by a mutation observer may involve the same attribute twice. Say a timer element is observed and suffers this sequence:

timer.setAttribute('enabled', false);
timer.setAttribute('cycleInterval', 10);    
timer.setAttribute('enabled', true);

The callback of the mutation observer then is invoked after the 'enabled' attribute is reset to true, and the sequence of mutations passed to the callback includes all three changes. Currently, the callback cannot know that the 'enabled' value was set to false after the first change occurred. Information is lost.

As a remedy, the MutationRecord interface could include a
readonly attribute DOMString? value;
attribute which holds the value of the changed attribute at the time when the record was observed. This way the sequence of recorded mutations contains a complete history and no information is lost.

@andreasplesch
Copy link
Author

Since enhancement moved to whatwg#376

@chaals chaals reopened this Nov 21, 2016
@andreasplesch
Copy link
Author

see whatwg#376 (comment) and response
for reference. Perhaps if there are more and widely applicable use cases there will be more consideration. My use case is very focused.

@yongsheng
Copy link
Collaborator

yes, I also think it could work by using 'oldValue'.

@xfq
Copy link
Member

xfq commented Dec 18, 2017

@yongsheng Can this issue be closed then?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants