W3C home > Mailing lists > Public > www-svg@w3.org > March 2009

Re: Script in SVG vs. HTML (was: Input on the agenda)

From: Jonas Sicking <jonas@sicking.cc>
Date: Tue, 10 Mar 2009 18:01:03 -0700
Message-ID: <63df84f0903101801v2874ed2fsb4758da0c0f69411@mail.gmail.com>
To: Jonas Sicking <jonas@sicking.cc>, Doug Schepers <schepers@w3.org>, public-html@w3.org, www-svg <www-svg@w3.org>
On Tue, Mar 10, 2009 at 4:20 PM, Cameron McCormack <cam@mcc.id.au> wrote:
> Doug Schepers:
>> > Along not-entirely-unrelated lines, the SVG WG is currently looking at
>> > aligning SVG script handling with that of HTML.  Feedback on this topic is
>> > most welcome.
>
> Jonas Sicking:
>> This is amazing news. It would be great if authors didn't have to use
>> different rules for composing <script>s inside the SVG parts vs. the
>> HTML parts of a single document.
>>
>> I think the best thing we can do for this is to ensure that developers
>> have access to tools that provide proper XML serialization of an SVG
>> fragment. This would take care of casing things properly, nesting
>> tags correctly, quoting attributes and wrapping the contents of
>> <script>s in <!CDATA[]]>. We already have code in gecko to do this,
>> I would imagine most other UAs do to as it is required to implement
>> XMLHttpRequest.
>
> How about being able to right click on an SVG fragment in a text/html
> document (or even an XHTML document) and choosing “Save image as…” to
> save it out as XML?

That sounds like a good idea.

>> 3.
>> What to do with <![CDATA[]]>. If we do parse as <script> as CDATA
>> (rather than PCDATA) that means that existing XML-SVG like
>>
>> <script>
>> <![CDATA[
>> alert('hello world');
>> ]]>
>> </script>
>>
>> would lead to the "<![CDATA[" and "]]>" being treated as part of the
>> javascript, and result in a JS parse error. I think we can solve this
>> by allowing the element to strip a heading "<![CDATA[" and trailing
>> "]]>", if they exist, before sending anything to the JS
>> implementation. I don't have a strong opinion on if this should be
>> allowed for both SVG-script and HTML-script, or just the former.
>> Consistency is always nice of course.
>
> The commented-out proposal in HTML 5 at the moment does handle CDATA
> sections explicitly, and turns them into Text nodes in the DOM.  This
> handling works for CDATA sections appearing anywhere in foreign content.
> I think this is useful, and not problematic.
>
> I agree about the consistency: I wonder if there would be any problems
> in allowing CDATA sections in HTML content?

I haven't looked at how the commented out proposal currently handles
SVG <script> elements. However I do think they should be handled as
similar as possible, ideally identical.

I would really like to explore allowing <![CDATA[]]> in HTML. Not sure
if we could allow it inside <script>s though, but it's something to
look into.

> Should <svg:script> also support the async and defer attributes?

I think that would be ideal. I think the advantages it brings to HTML
would benefit SVG just as much. Both in text/html and in image/svg+xml

/ Jonas
Received on Wednesday, 11 March 2009 01:01:43 GMT

This archive was generated by hypermail 2.3.1 : Friday, 8 March 2013 15:54:41 GMT