On Monday, October 27, 2014 12:33:33 PM UTC-7, whatever wrote:
>
> Hi!
> I figured it out, in case anyone is interested. Instead of using
> setAttribute on the element, I had to use this.nextSibling.firstChild.src,
> because the image is the first child of the next sibling of the textarea.
> Same for title and alt. The setAttribute approach worked in pure HTML file
> though.
>
The browser's javascript engine overloads the assignment operator so that
*directly* setting certain attributes will have side effects. Although
using setAttribute() will store the value in the element, it does not
trigger the side effect processing. You can see this when setting
"innerHTML" on an element. It not only sets the attribute, but it also
removes any previously rendered DOM 'sub-tree', and then generates an
entirely new DOM sub-tree based on the new attribute value. Similarly,
setting the 'src' of an image element needs to use direct assignment to
trigger the re-rendering of the image. Thus,
image_element.setAttribute('src','URL');
will not update the image display, while
image_element.src='URL';
will cause the image to change.
-e
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.