__defineSetter__ on innerHTML stops it from rendering

I am trying to create a watch method for HTML elements using __define[GS]etter__properties when changing. It reacts great when I set the value, but if the property being listened is innerHTML, it somehow cannot display the given string. So basically when I add something to innerHTML, it is not displayed.

Im using the clock method described in this previous question: Watch for changes to the properties of objects in JavaScript

I might just not listen to the innerHTML changes, but I also wonder if __defineSetter__somehow it prevents the initial processing of setting the value.

Thank!

0
source share
3 answers

This cushioning code is not actually written: when you set the property, the value is remembered only on the watch browser and is not transmitted to the base object. It is intended for pure JavaScript objects whose properties have no side effects (for example, changing the DOM in the case innerHTML).

Recording through recording will be a pain, because there is no way to directly call the prototype setter. You will have to temporarily remove the property, write to the base property, and then return it to its place.

However, this is not worth pursuing IMO. DOM nodes are allowed to be "host objects", so there is no guarantee that any functions of the native-JavaScript property object will work on them at all.

( Object .)

innerHTML

, , .

0

. MSDN, , : http://msdn.microsoft.com/en-us/library/dd229916(VS.85).aspx

Object.getOwnPropertyDescriptor , -, IE. . .

0

- - , , : http://www.refactory.org/s/recent/tag/accessors

, - , evnets , .

But if anyone finds a solution for the plz post question :)

0
source

All Articles