attributeChanged not firing.

48 views
Skip to first unread message

sam...@gmail.com

unread,
Jun 11, 2014, 8:47:49 AM6/11/14
to polym...@googlegroups.com
Hey all.

I was wondering why changing an attribute doesnt seem to fire "attributeChanged". I made a fiddle here: http://jsfiddle.net/4awvr/ and using the development tools to change the attribute "test" shows my issue.

Thanks,

Sam

Scott Miles

unread,
Jun 11, 2014, 9:08:22 AM6/11/14
to sam...@gmail.com, polymer-dev
Seems to work in this jsbin (make sure you open the 'console' panel): http://jsbin.com/gejeq/1/edit

Does it work for you? If not, please describe the browser platform you are testing on.


Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/65a5af3c-7435-40db-887f-79bfff22658a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

sam...@gmail.com

unread,
Jun 11, 2014, 11:06:32 AM6/11/14
to polym...@googlegroups.com, sam...@gmail.com
Hmm... so I've found a peculiar problem that caused this.

document.getElementsByName('somename')[0] does not have the setAttribute method so it wasn't working.

I was (for some reason that has since been rectified) passing that vanilla element reference to jQuery and setting the attributes there, which was updating the DOM when inspected, but was not triggering Polymer.

FWIW if you edit the attribute from the DOM Inspector it also doesn't update Polymer!

Scott Miles

unread,
Jun 11, 2014, 2:42:36 PM6/11/14
to sam...@gmail.com, polymer-dev
>> document.getElementsByName('somename')[0] does not have the setAttribute method so it wasn't working.

If that expression doesn't return null, it will have a setAttribute method. However, `document.getElementsByName('foo')` is actually returning elements that have an attribute with `name="foo"`;  are you intending to use `getElementsByTagName`? If you are actually using `getElementsByName` you should probably just stop (our DOM engineer says it's "an abomination", lol).

>> passing that vanilla element reference to jQuery and setting the attributes there

Today, ShadowDOMPolyfill does not provide a patched version of `getElementsByName`; if you really want to use it you have to `wrap` the return value:

var element = wrap(document.getElementsByName('somename')[0]);

>> FWIW if you edit the attribute from the DOM Inspector it also doesn't update Polymer!

On platforms using ShadowDOMPolyfill, you have to be careful what techniques you use use to poke elements in the dev tools. If you stick to 'querySelector' you generally will be ok. If you describe exactly what you are doing in the console (and in what browser) I can give you more information.

Scott


Reply all
Reply to author
Forward
0 new messages