Jorge wrote:
> Garrett Smith wrote:
>> Jorge wrote:
>> (...)
>>> 1.- WTHIT ?
>>
>> I take it that means "what the hell is this". It is an MSIE property.
>> I should have mentioned that |canHaveHTML| is an MSIE property[5].
>> (...)
>> AISB, it is based on the expectation that all browsers violate HTML
>> 4.01 to make it work.
>> (...)
>
> True, <script>s can (and should) not contain *markup* and nobody is
> asking for it. In the absence of (inner) markup, .innerHTML becomes ===
> .innerText === .textContent === .text. If it makes you feel any better
> use the latter. Although -I can only guess- they must have chosen
> .innerHTML for a reason.
>
Script content is CDATA[1]. That means it must *not* contain markup.
While that is true, it is not the incompliance that I mention.
What I am talking about is the HTML 4.01 requires the browser to ignore
the element's contents when the script has a URI. See HTML 4.01, 18.2.1
The SCRIPT element:
| If the src attribute is not set, user agents must interpret the
| contents of the element as the script. If the src has a URI value,
| user agents must ignore the element's contents and retrieve the script
| via the URI.
"*must* *ignore*"
And 6.14 Script data:
| User agents must not evaluate script data as HTML markup but instead
| must pass it on as data to a script engine.
And section 6.2 SGML basic types:
| ...
| Although the STYLE and SCRIPT elements use CDATA for their data model,
| for these elements, CDATA must be handled differently by user agents.
| Markup and entities must be treated as raw text and passed to the
| application as is.
Now, in a browser that does not support the script element, it should,
(or must, in other specifications) attempt to process the element's
content.
HTML 4.01, B.1 Notes on invalid documents:
| # If a user agent encounters an element it does not recognize, it
| should try to render the element's content.
XHTML 1, 3.2. User Agent Conformance:
| # If a user agent encounters an element it does not recognize, it must
| process the element's content.
The choice of judgment to use |script.innerHTML| is based on the
expectation that the script will have an innerHTML property containing
the script data as text, that gets passed as-is to eval. That
expectation is, according to Steve Souders, based upon what "all
browsers" do.
Garrett
--
comp.lang.javascript FAQ:
http://jibbering.com/faq/