Re: Mutation events replacement

On Wed, Jul 6, 2011 at 1:27 AM, Dave Raggett <dsr@w3.org> wrote:

> On 04/07/11 21:43, Olli Pettay wrote:
>>
>> In the easiest case when the script cares about only one specific
>> attribute:
>> element.**addAttributeChangeListener(
>>  {
>>    prevVal: element.getAttribute("foo"),
>>    handleMutation: function(node, changeTarget) {
>>      if (node == changeTarget) {
>>        // do something with this.prevVal
>>        ...
>>        this.prevVal = element.getAttribute("foo");
>>      }
>>    }
>>  });
>>
>
> How does that scale to the case where you set the observer on the document
> or on a div element acting as a contained for content editable content?  If
> I am not mistaken you would have to keep a copy of the document, or of that
> div element respectively, and keep it in sync with all of the mutations,
> which sounds like a major performance hit, and something you don't need to
> incur with the current DOM mutation events.


We should probably include the old value optionally.

- Ryosuke

Received on Wednesday, 6 July 2011 15:53:33 UTC