Thanks Tab, and everyone else. This has been enlightening!<div><br><br><div class="gmail_quote">On Tue, Dec 8, 2009 at 3:22 PM, Tab Atkins Jr. <span dir="ltr"><<a href="mailto:jackalmage@gmail.com">jackalmage@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Some clarification is in order; I didn't answer fully and was<br>
corrected elsewhere.<br>
<br>
There are two distinct notions of attributes here. The first, the<br>
"content attribute", is what you're manipulating when you do<br>
foo.setAttribute() or foo.getAttribute(). The second, the "IDL<br>
attribute" (may be called "DOM attribute" or "property" in some<br>
places) is what you're manipulating when you do foo.bar (where foo is<br>
an element and bar is an attribute name).<br>
<br>
The content attribute can exist or not; if it exists, it's considered<br>
'on', and if it doesn't it's considered 'off'. It's a string, and if<br>
specified must be one of the two values I mentioned previously.<br>
<br>
The IDL attribute is a boolean. It's either true or false. Setting<br>
it to true will set the content attribute, and setting it to false<br>
will remove the content attribute.<br>
<br>
So "script.async=true" is valid and does what you would expect.<br>
Similarly, "script.async=false" is valid and does what you would<br>
expect. "script.setAttribute('async','true')" is invalid, but still<br>
makes the element async. "script.setAttribute('async','false')" is<br>
invalid, and also makes the element async, which is not what you would<br>
naively expect.<br>
<br>
If you want to get more confusing, "script.async='true'" makes the<br>
element async, because in javascript non-empty strings evaluate as<br>
true. However, "script.async='false'" would also make it async, while<br>
"script.async=''" doesn't. You have to pay attention to what you're<br>
actually dealing with.<br>
<font color="#888888"><br>
~TJ<br>
</font></blockquote></div><br></div>