Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

E4X support in mozilla?

18 views
Skip to first unread message

Mario Klaue

unread,
Dec 30, 2004, 6:30:59 PM12/30/04
to
Hello,

does anybody know how and when to get the opportunity to play with
ECMAScript for XML (E4X) in a browser?

Thanks.

Mario Klaue


Brendan Eich

unread,
Dec 30, 2004, 10:21:23 PM12/30/04
to Mario Klaue
Mario Klaue wrote:
> Hello,
>
> does anybody know how and when to get the opportunity to play with
> ECMAScript for XML (E4X) in a browser?


It's about to be turned on for 1.8a6. It will be enabled by default in
XUL scripts and in JS XPCOM components. To enable it in HTML script
tags, you'll have to specify type="application/x-javascript;e4x=1" or
type="text/javascript;e4x=1" in the tag.

/be

Marek Lewczuk

unread,
Jan 1, 2005, 5:32:43 AM1/1/05
to Brendan Eich, Mario Klaue
Brendan Eich napisał(a):

Brendan,
Can you tell what is the current status of Javascript 2.0 ? Thanks in
advance for any answer.

ML

Shanti Rao

unread,
Jan 2, 2005, 1:13:20 AM1/2/05
to

Hi Brendan,

Though terrified, I might as well make the best of it.

1. Is the version number going to change to 1.6 or similar?

2. How can I get the current SM code for E4X? Is it in the nightly tarballs?

Thanks,

Shanti

Brendan Eich

unread,
Jan 2, 2005, 12:43:20 PM1/2/05
to Shanti Rao
Shanti Rao wrote:

> Brendan Eich wrote:
>
>> To enable it in HTML script tags, you'll have to specify
>> type="application/x-javascript;e4x=1" or type="text/javascript;e4x=1"
>> in the tag.
>>
>> /be
>
>
> Hi Brendan,
>
> Though terrified, I might as well make the best of it.


Why terrified? E4X won't hurt ya! ;-)


> 1. Is the version number going to change to 1.6 or similar?


No. E4X is orthogonal to the JS version. The way to select it is with
the MIME type. The language= attribute has been deprecated by HTML 4.x
for a while now (for all that's worth ;-).


> 2. How can I get the current SM code for E4X? Is it in the nightly
> tarballs?


It's in the CVS trunk so any release off the trunk (nightly builds,
didn't know we released tarballs) will have it.

/be

Shanti Rao

unread,
Jan 2, 2005, 6:50:49 PM1/2/05
to
Brendan Eich wrote:
> Shanti Rao wrote:
>
>> Brendan Eich wrote:
>>
>>> To enable it in HTML script tags, you'll have to specify
>>> type="application/x-javascript;e4x=1" or type="text/javascript;e4x=1"
>>> in the tag.
>>>
>>> /be
>>
>>
>>
>> Hi Brendan,
>>
>> Though terrified, I might as well make the best of it.
>
> Why terrified? E4X won't hurt ya! ;-)

<rant>
Ain't broke, don't fix. It's not hard to write a fault-tolerant XML parser in
JS, and how do I know that the choices made in designing E4X are going to be
the ones I desire or expect? See earlier discussion about JS2.0 for inherent
reticence to embrace changes to languages that underpin complex systems.

E4X appears to take a vocabulary (E) and force it onto an object model (X). I
would have been a lot happier if the designers had started with a clear data
processing objective, and invented a vocabulary to match. What we have now
looks a lot like a camel.

Consider some sample code from
http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-357.pdf

var twoemployees = e.employee.(@id == 0 || @id == 1);
for each (var p in e..employee) { ... }

What's this @ stuff? Perl is the language of obscure punctuation, not
JavaScript! I just know that some newbie is going to look at that and think
that they can get away with that sort of syntax for any JS object, then call
me and wonder why it doesn't work. Then they'll ask how many dots are supposed
to be between e and employee. And I won't have a clue?

I wish that the E4X designers had put compactness of syntax secondary to
clarity of purpose.
</rant>

>> 1. Is the version number going to change to 1.6 or similar?
>
> No. E4X is orthogonal to the JS version. The way to select it is with
> the MIME type. The language= attribute has been deprecated by HTML 4.x
> for a while now (for all that's worth ;-).

There have been enough changes since 1.5rc6a that you might consider a new
version number. The ATLINE option is new, and XML hooks are pervasive.

I'm reading through jsxml.c, and notice that you sensibly observe that >
escaping isn't necessary. Can you explain the testcase

It will be interesting to figure out how namespaces work. Do namespaces go
into the global string hash table?

>> 2. How can I get the current SM code for E4X? Is it in the nightly
>> tarballs?
>
>
> It's in the CVS trunk so any release off the trunk (nightly builds,
> didn't know we released tarballs) will have it.

ftp://ftp.mozilla.org/pub/mozilla.org/mozilla/nightly/latest-trunk/mozilla-source.tar.bz2
>
> /be

Thanks,

Shanti

Brendan Eich

unread,
Jan 3, 2005, 5:07:01 PM1/3/05
to Shanti Rao
Shanti Rao wrote:

> <rant>
> Ain't broke, don't fix. It's not hard to write a fault-tolerant XML
> parser in JS, and how do I know that the choices made in designing E4X
> are going to be the ones I desire or expect?


E4X folks designed (and hacked, a lot -- one prototype based on Rhino
predates the standard, woohoo!) with XQuery and other XML standards in
mind. They separated data model from syntax, and built on xml-infoset
(errata notwithstanding; the spec's being fixed for ISO).


> See earlier discussion
> about JS2.0 for inherent reticence to embrace changes to languages that
> underpin complex systems.


That's a bit to general to work with. :-/


> E4X appears to take a vocabulary (E) and force it onto an object model
> (X). I would have been a lot happier if the designers had started with a
> clear data processing objective, and invented a vocabulary to match.


I'm pretty sure they did that, but I wasn't around, so I'll defer to
others who may know better.


> What we have now looks a lot like a camel.


Camels are useful, even if Ugly. You know you're dangerously close to
insulting Perl here... ;-)


> Consider some sample code from
> http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-357.pdf
>
> var twoemployees = e.employee.(@id == 0 || @id == 1);
> for each (var p in e..employee) { ... }
>
> What's this @ stuff?


Attributes are in a separate namespace with a distinct operator
prefixing literal name uses. This is based directly on XQuery, IIRC.


> Perl is the language of obscure punctuation,


You're now over the edge.

Look, @attrname is not obscure, and if you don't like at-signs, think of
them as "at"tribute signs. JS+E4X is not Perl by a long shot, but I'm
not about to join you in knocking Perl. And I don't mean Perl 6,
either, I mean Perl 5, hack that it is. Hacks can be useful.


> I just know that some newbie is going to look at that and
> think that they can get away with that sort of syntax for any JS object,
> then call me and wonder why it doesn't work.


They'll get a clear diagnostic. You can't write 42() in JS and have it
evaluate to 42, either -- why aren't newbies confused by that? Newbies
don't just throw in @ because it looks cool (or you have a lower grade
of newbie than you should tolerate).


> Then they'll ask how many
> dots are supposed to be between e and employee. And I won't have a clue?


... is used in C-like languages, but maybe three times is the charm.


> I wish that the E4X designers had put compactness of syntax secondary to
> clarity of purpose.


In a few places, I agree with you, but JS already loses to Python (never
mind Perl) in the estimation of people I respect because of JS's C/Java
verbosity, both for block structure and control keywords, and in the
lower-level sub-grammars. And Python is winning while we all wait for
Perl 6.

So there has to be a fine balance between conciseness and readability,
and I think E4X gets it mostly right.


> There have been enough changes since 1.5rc6a that you might consider a
> new version number. The ATLINE option is new, and XML hooks are pervasive.


JSOPTION_ATLINE is a tiny API option for XUL preprocessing, it hardly
merits a version trip.

The XML hooks are indeed pervasive, but that's an implementation detail.
The language doesn't change unless you both compile-time enable *and*
run-time enable E4X. The version number is for the language, not for
the implementation.


> I'm reading through jsxml.c, and notice that you sensibly observe that >
> escaping isn't necessary. Can you explain the testcase


What testcase?


> It will be interesting to figure out how namespaces work. Do namespaces
> go into the global string hash table?


What global string hash table? I think you are mixing up implementation
details, but if you have a language question about namespaces, I can
help. E4X namespaces are being made consistent with namespaces in
Edition 4 (JS2, ActionScript 2).

/be

Shanti Rao

unread,
Jan 3, 2005, 6:00:16 PM1/3/05
to

> don't just throw in @ because it looks cool (or you have a lower grade
> of newbie than you should tolerate).

Well, my newbies are corporate IT-types. Visual Basic and JavaScript are what
they're familiar with, and they find Python scary and UNIX-centric (though
it's getting better) and Perl unreadable.

Perhaps it's inevetible that a language aquires complexity until it's
sufficient complex that an opportunity for a new language is created?

Shanti

Brendan Eich

unread,
Jan 3, 2005, 10:46:04 PM1/3/05
to Shanti Rao
Shanti Rao wrote:
>
> Perhaps it's inevetible that a language aquires complexity until it's
> sufficient complex that an opportunity for a new language is created?


Possibly, and there should be, and will be, new and better languages
(already are, but since worse is better, many "better" ones lost in a
Darwinian who's-on-first contest).

But I'd say JS+E4X is ahead of the curve, judging from the rise of XML
and the E4X envy seen among the Python and Ruby folks ;-). And the
complexity is not terrible, but I agree it could be simpler. Adding
namespaces is a big complexity increase, and all evidence we and others
(Micah Dubinko, e.g.) have say that namespaces are the most error-prone
part of practical XML.

But that's a problem not peculiar to E4X.

/be

Shanti Rao

unread,
Jan 4, 2005, 1:43:01 PM1/4/05
to
Brendan,

1. What's JSScript::numGlobalVars for?

2. Do you recommend editing jsconfig.h to set JS_HAS_XML_SUPPORT = 1?

Thanks,

Shanti

Brendan Eich

unread,
Jan 5, 2005, 10:31:14 PM1/5/05
to Shanti Rao
Shanti Rao wrote:
> Brendan,
>
> 1. What's JSScript::numGlobalVars for?


It counts one more than the greatest atom index of all declared global
variables and regular expressions in the script. It's used for the fast
global optimization (see bug 169559, fixed, and follow-on bug 276249).


> 2. Do you recommend editing jsconfig.h to set JS_HAS_XML_SUPPORT = 1?


It's on in the CVS trunk, so I should think so! ;-)

/be

Georg Maaß

unread,
Jan 6, 2005, 10:39:41 AM1/6/05
to
Brendan Eich wrote:
> You can't write 42() in JS and have it
> evaluate to 42,

Are you sure?

I get, what I expect:

Error: number is not a function

This is not 42.


--
Georg Maaß - bioshop.de D-76227 Karlsruhe, Westmarkstraße 82
HTML, XML / JavaScript, C++, Java, PHP, VB / CGI, JSP, ASP, ASP.net
- The ultimate DHTML engine: http://gml-modul.sourceforge.net -
http://sourceforge.net/projects/gml-modul

Brendan Eich

unread,
Jan 6, 2005, 1:46:39 PM1/6/05
to Georg Maaß
Georg Maaß wrote:
> Brendan Eich wrote:
>
>> You can't write 42() in JS and have it evaluate to 42,
>
>
> Are you sure?
>
> I get, what I expect:
>
> Error: number is not a function
>
> This is not 42.


Right -- I wrote "can't", not "can" above ;-).

Have you had a chance to try E4X in SpiderMonkey yet? The DOM binding
is not done yet, but you can write

<script type="text/javascript;e4x=1">
var x = <t><u id="1">one</u><u id="2">two</u><u id="3">three</u></t>;
alert(x.toXMLString());
</script>

and other such things. E4X is also enabled in JS XPCOM components, and
it's being used there for the Lightning project
(http://wiki.mozilla.org/index.php/Calendar:Lightning).

/be

Martin Honnen

unread,
Jan 6, 2005, 3:09:45 PM1/6/05
to

Brendan Eich wrote:


> <script type="text/javascript;e4x=1">
> var x = <t><u id="1">one</u><u id="2">two</u><u id="3">three</u></t>;
> alert(x.toXMLString());
> </script>

What is happening if I have several script elements in a HTML document,
some saying
<script type="text/javascript;e4x=1">
some
<script type="text/javascript">
will they share variables? It seems they do here with a Mozilla nightly
some days old.

It also seems
typeof XML
is function event in
<script type="text/javascript">
blocks. Does that mean it is possible to construct native XML object
with new XML() in <script type="text/javascript"> blocks, only parsing
of XML "literals" wouldn't work there?

As for that <script type="text/javascript;e4x=1"> Content-Type notation,
is that something that Mozilla has "invented" to enable web developers
to distinguish between "normal" JavaScript and E4X enabled JavaScript or
is that something the participants in the ECMA working group have agreed
on? Unfortunately Opera browers for instance try to consume such <script
type="text/javascript;e4x=1"> and then obviously throw syntax errors.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Shanti Rao

unread,
Jan 6, 2005, 6:21:33 PM1/6/05
to
Well, I've compiled it, and it seems to work. It even seems to coexist with my
existing XML classes. If anyone wants, there's a precompiled Windows binary at
www.jsdb.org.

Shanti

Brendan Eich

unread,
Jan 6, 2005, 6:47:36 PM1/6/05
to Martin...@gmx.de
Martin Honnen wrote:
>
>
> Brendan Eich wrote:
>
>
>> <script type="text/javascript;e4x=1">
>> var x = <t><u id="1">one</u><u id="2">two</u><u id="3">three</u></t>;
>> alert(x.toXMLString());
>> </script>
>
>
> What is happening if I have several script elements in a HTML document,
> some saying
> <script type="text/javascript;e4x=1">
> some
> <script type="text/javascript">
> will they share variables? It seems they do here with a Mozilla nightly
> some days old.


Sure, scripts in the same document all share the same global object,
namely the window object.

This doesn't change, nor should it.

What does change, and it's big in terms of web compatibility, is that
the old-as-JS "script hiding hack" for hiding inline script content from
browsers that don't understand JS (are there any, nowadays?):

<script language="JavaScript">
<!-- hide from old browsers
function foo() {...}
// etc.
// done hiding from old browsers -->
</script>

does not work in <script type="text/javascript; e4x=1">...</script>
content, because E4X says that <!-- starts an XML comment.


> It also seems
> typeof XML
> is function event in
> <script type="text/javascript">
> blocks. Does that mean it is possible to construct native XML object
> with new XML() in <script type="text/javascript"> blocks, only parsing
> of XML "literals" wouldn't work there?


Yes. I didn't want to add unnecessary runtime checks, and reckoned that
it's better to define XML unconditionally. This smoked out some const
XML = ... cases in Firefox help, but they turned out to be dead consts,
and they were removed.

If predefining XML, XMLList, Namespace, QName, and isXMLName breaks
compatibility too much, we can add more runtime option-checking. But I
want to find out, so getting this level of support into 1.8a6 should,
and getting that alpha wide distribution and testing among hackers who
can report good bugs, will help.


> As for that <script type="text/javascript;e4x=1"> Content-Type notation,
> is that something that Mozilla has "invented" to enable web developers
> to distinguish between "normal" JavaScript and E4X enabled JavaScript or
> is that something the participants in the ECMA working group have agreed
> on?


It's Mozilla-only, and E4X implemented in SpiderMonkey is the first such
browser implementation that I know of. Someone tell me if there's
another browser that does E4X already.

I'm trying to get the ECMA TG1 group to help the w3c do the right thing
with the content types that the w3c has made up without bothering to
register them with the IETF (nowadays, with the IANA -- see
http://www.iana.org/).


> Unfortunately Opera browers for instance try to consume such <script
> type="text/javascript;e4x=1"> and then obviously throw syntax errors.


That is unfortunate. Does Opera do anything with any version parameter
(or with "JavaScript1.2" as the language attribute's value, if type is
not used)? We could make a new version of the language, but if it
doesn't help hide E4X content from other browsers, then there's no point.

As you'd expect from past history with other JS innovations (if anyone
recalls the JS1.2 and ECMA Editions 1-3 rollouts), attempts to use E4X
on the web will require good browser sniffing and content selection on
the server side, not just good script tag version/option control in
static content.

In the mean while, E4X is good for use in private pages, and especially
in JS XPCOM components and in XUL. Even without the DOM two-way binding
that remains to be done, it's handy.

/be

Bob Clary

unread,
Jan 6, 2005, 7:38:03 PM1/6/05
to
Brendan Eich wrote:
>> Unfortunately Opera browers for instance try to consume such <script
>> type="text/javascript;e4x=1"> and then obviously throw syntax errors.
>
>
>
> That is unfortunate. Does Opera do anything with any version parameter
> (or with "JavaScript1.2" as the language attribute's value, if type is
> not used)? We could make a new version of the language, but if it
> doesn't help hide E4X content from other browsers, then there's no point.

neither Opera or Konqueror respect language version specified by the
|language| or |type| attributes of the script tag. like mikey, they will
attempt to execute anything.

Shanti Rao

unread,
Jan 7, 2005, 2:25:40 AM1/7/05
to
Brendan Eich wrote:
> Shanti Rao wrote:
>
>> Brendan,
>>
>> 1. What's JSScript::numGlobalVars for?
>
>
>
> It counts one more than the greatest atom index of all declared global
> variables and regular expressions in the script. It's used for the fast
> global optimization (see bug 169559, fixed, and follow-on bug 276249).
>

It looks like if you want to serialize a script, you're limited to 65535
global objects? I'm noticing that js_XDRScript() only keeps 16 bits at
jsscript.c#429. Does anyone even use that feature anymore? Is the iPlanet
server still in print?

Shanti

Martin Honnen

unread,
Jan 7, 2005, 10:11:21 AM1/7/05
to

Brendan Eich wrote:


>> It also seems
>> typeof XML
>> is function event in
>> <script type="text/javascript">
>> blocks. Does that mean it is possible to construct native XML object
>> with new XML() in <script type="text/javascript"> blocks, only parsing
>> of XML "literals" wouldn't work there?
>
> Yes.

Should trying to parse XML source from string with
new XML('<root>content</root>')
work then in <script type="text/javascript" blocks?
It seems it doesn't, the XML function is available but calling it with
some well-formed XML causes an error, test case is here
<http://home.arcor.de/martin.honnen/javascript/200501/test2005010703.html>
Error in the JavaScript console is

Error: invalid XML markup
Source File:
Line: 1
Source Code:
<parent xmlns=''><god>Kibo</god></parent>

tested with Mozilla 1.8a nightly 2005010606.

If I use <script type="text/javascript; e4x=1"> then all is fine:
<http://home.arcor.de/martin.honnen/javascript/200501/test2005010702.html>
so maybe I am just misunderstanding your "yes" above.

Would it be possible to enable e4x in the xpcshell.exe that is build
with Mozilla nightlies? That way one could test core e4x functionality
there.

Brendan Eich

unread,
Jan 7, 2005, 1:10:08 PM1/7/05
to Shanti Rao
Shanti Rao wrote:

> It looks like if you want to serialize a script, you're limited to 65535
> global objects? I'm noticing that js_XDRScript() only keeps 16 bits at
> jsscript.c#429. Does anyone even use that feature anymore? Is the
> iPlanet server still in print?


Yes, XDR is used every time you restart Firefox, Thunderbird, Mozilla,
etc. as part of XUL FastLoad.

No, there's no new limit here: atom indexes stored as immediate operands
in bytecode were always two bytes, so always limited to maximum value of
65535.

/be

Brendan Eich

unread,
Jan 7, 2005, 1:14:57 PM1/7/05
to Martin...@gmx.de
Martin Honnen wrote:
>
> Should trying to parse XML source from string with
> new XML('<root>content</root>')
> work then in <script type="text/javascript" blocks?


No, you need to enable e4x=1. Again, the XML constructor is exposed to
catch name collisions, not to be useful without the option parameter in
the MIME type.

If this seems wrong, let me know what's less wrong:
(1) turning off XML, etc., in the absence of e4x=1;
(2) magically turning E4X support on in spite of no e4x=1 when a script
calls XML, or Namespace, or ....

I think (2) is crazy. (1) is do-able, but again, I wanted to smoke out
name collisions during 1.8a6.

/be

Martin Honnen

unread,
Jan 7, 2005, 2:56:36 PM1/7/05
to

Brendan Eich wrote:

> Martin Honnen wrote:
>>
>> Should trying to parse XML source from string with
>> new XML('<root>content</root>')
>> work then in <script type="text/javascript" blocks?
>
> No, you need to enable e4x=1. Again, the XML constructor is exposed to
> catch name collisions, not to be useful without the option parameter in
> the MIME type.

OK, fine with me, just wanted to understand.

Bob Clary

unread,
Jan 7, 2005, 8:34:13 PM1/7/05
to
Bob Clary wrote:

>
> neither Opera or Konqueror respect language version specified by the
> |language| or |type| attributes of the script tag. like mikey, they will
> attempt to execute anything.

To clarify:

<http://bclary.com/2004/09/26/javascript/external.html>
<http://bclary.com/2004/09/26/javascript/inline.html>

Firefox 1.0 WinXPSP2
Executes language attribute version up to 1.5
Executes if type="text/javascript;version=xx" up to 1.5
Executes if type="text/javascript;e4x=1"
js language == 1.5
js type == 1.5
e4x == 1

MSIE6 WinXPSP2
Executes language attribute version up to 1.3
Executes if type="text/javascript", ignores if version specified
Ignores if type="text/javascript;e4x=1"
js language == 1.3
js type == default
e4x == undefined

Opera 7.54 WinXPSP2
Executes language attribute version up to 1.5
Executes if type="text/javascript;version=xx" up to anything
Executes if type="text/javascript;e4x=1"
js language == 1.5
js type == 99.99
e4x == 1

Konqueror 3.2.1 SuSe 9.1
Executes language attribute version up to anything
Executes if type="text/javascript;version=xx" up to anything
Executes if type="text/javascript;e4x=1"
js language == 99.99
js type == 99.99
e4x == 1

Nickolay Ponomarev

unread,
Jan 8, 2005, 3:38:51 AM1/8/05
to
Brendan Eich wrote:
>In the mean while, E4X is good for use in private pages, and
>especially in JS XPCOM components and in XUL. Even without binding
>the DOM two-way that remains to be done, it's handy.

Is E4X supposed to work in XUL scripts now? I tried to load the
following XUL file, and it didn't work (I tried it without type
attribute and from an extension; tested with 20040107 Firefox build).
Your example above (script in an HTML file) worked...

Nick

The XUL file:
----
<window
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript;e4x=1"><![CDATA[


var x = <t><u id="1">one</u><u id="2">two</u><u id="3">three</u></t>;
alert(x.toXMLString());
]]></script>

</window>
----

Georg Maaß

unread,
Jan 8, 2005, 1:50:14 PM1/8/05
to
Brendan Eich wrote:
> No, you need to enable e4x=1. Again, the XML constructor is exposed to
^
What is this 1? Is this a flag, or is it a version number, or what is
the meaning of this 1?

Greetings, Georg

Brendan Eich

unread,
Jan 8, 2005, 5:09:26 PM1/8/05
to Georg Maaß
Georg Maaß wrote:
> Brendan Eich wrote:
>
>> No, you need to enable e4x=1. Again, the XML constructor is exposed to
>
> ^
> What is this 1? Is this a flag, or is it a version number, or what is
> the meaning of this 1?

That's a good question. MIME parameters need values, so we can't have
just e4x. Also, the E4X spec adopted by ECMA is likely to be ECMA-357
Edition 1, and the fixed (see the errata in bug 246441) spec going to
ISO shortly will become ECMA-357 Edition 2.

So I meant to use that 1 as a "truth" value at first, but quickly saw
that it was likely to mean "Edition 1". Either way, it works, but I
would rather not support all Editions. I'll talk to the TG1 working
group about this, since we're trying to get the w3c to do the right
thing instead of making up MIME types, and since ECMA's name (or at
least its initial) is being used here.

/be

Martin Honnen

unread,
Jan 31, 2005, 1:20:05 PM1/31/05
to
[following up a thread some weeks old so here is the context
<http://groups-beta.google.com/group/netscape.public.mozilla.jseng/browse_frm/thread/d27a5cb06aba787/d212aed336d5cf60?q=group:netscape.public.mozilla.jseng+insubject:e4x&_done=%2Fgroups%3Fsafe%3Dimages%26as_ugroup%3Dnetscape.public.mozilla.jseng%26as_usubject%3De4x%26lr%3D%26hl%3Den%26&_doneTitle=Back+to+Search&&d#d212aed336d5cf60>]

Brendan Eich wrote:
> Martin Honnen wrote:
>

>> Unfortunately Opera browers for instance try to consume such <script
>> type="text/javascript;e4x=1"> and then obviously throw syntax errors.
>
> That is unfortunate.

I have just found that existing Mozilla versions like Firefox 1.0 or
Mozilla 1.7.2 also execute <script type="text/javascript;e4x=1">. Makes
sense, probably see that e4x as an unknown parameter to the recognized
MIME type text/javascript. Still I had hoped that at least for Mozilla
there is a way to include e4x script in a HTML page and avoid that
Mozilla versions that do not know e4x try to execute it. Is there
currently a way?

Brendan Eich

unread,
Feb 2, 2005, 9:21:33 PM2/2/05
to
Ian Hickson wrote:

>On Thu, 6 Jan 2005, Brendan Eich wrote:
>
>
>>What does change, and it's big in terms of web compatibility, is that
>>the old-as-JS "script hiding hack" for hiding inline script content from
>>browsers that don't understand JS (are there any, nowadays?):
>>
>>
>

>Don't understand <script>, not necessarily not understand JS.
>
>

True, I was inaccurate in my phrasing (but it's moot since JS was the
first and default <script> language ;-).

>>>Unfortunately Opera browers for instance try to consume such <script
>>>type="text/javascript;e4x=1"> and then obviously throw syntax errors.
>>>
>>>
>

>I raised this with our JS guys at Opera.
>
>

Any response? I shouldn't expect unknown MIME type parameters to cause
the script content to be ignored, so no worries. Martin pointed this
out in another post, thanks to him too.

>I have something to raise, though: is the ;e4x=1 format supported in the
>Default-Script-Type header, so that it sets the default for event handler
>attributes in HTML to have E4X support?
>
>

It's Content-Script-Type
(http://www.w3.org/TR/html401/interact/scripts.html#h-18.2.2.1),
atomized as headerContentScriptType at
http://lxr.mozilla.org/mozilla/source/content/html/content/src/nsHTMLAtomList.h#162,
but now seemingly not used? cc'ing jst and peterv. Since it seems we
don't use this atom, the answer to your question is "no, but we will
when we fix the broken content-script-type support!" ;-)

/be

Lars T Hansen

unread,
Feb 7, 2005, 7:41:37 AM2/7/05
to

Brendan Eich <bre...@meer.net> writes:

> Ian Hickson wrote:
>
> >>>Unfortunately Opera browers for instance try to consume such <script
> >>>type="text/javascript;e4x=1"> and then obviously throw syntax errors.
> >>>
> >>>
> >
> >I raised this with our JS guys at Opera.
> >
> >
>
> Any response? I shouldn't expect unknown MIME type parameters to cause
> the script content to be ignored, so no worries. Martin pointed this
> out in another post, thanks to him too.

I actually changed Opera's behavior in response to the earlier posts
in the thread, so that an unknown parameter would effectively disable
the script and trigger a NOSCRIPT block if present. Despite not being
backward compatible it seemed sensible: it would be analogous to
recognizing a parameter name but not its value (as in the case of
"text/javascript;version=2.0").

Martin Honnen asks for a backwards compatible mechanism whereby JS+E4X
will not be executed by engines that don't know it. For this, a new
language tag / MIME type seems unavoidable. I'm not sure that is such
a bad idea.

--lars


Karsten Düsterloh

unread,
Feb 11, 2005, 9:16:19 PM2/11/05
to
Nickolay Ponomarev aber hob zu reden an und schrieb:

So noone has a helpful answer to that?
I, too, tested several combinations of XUL/JS/E4X, but couldn't get to
work there. With HTML files it does - but in XUL files, not even
'hiding' it inside a (X)HTML namespace helps...


Karsten
--
Freiheit stirbt | Fsayannes SF&F-Bibliothek:
Mit Sicherheit | http://fsayanne.tprac.de/

Brendan Eich

unread,
Feb 11, 2005, 9:26:01 PM2/11/05
to kd-u...@tprac.de
Karsten Düsterloh wrote:

> I, too, tested several combinations of XUL/JS/E4X, but couldn't get to
> work there. With HTML files it does - but in XUL files, not even
> 'hiding' it inside a (X)HTML namespace helps...


XUL needs more help; I'll fix it for 1.8b2 to work.

/be

Karsten Düsterloh

unread,
Feb 11, 2005, 9:57:24 PM2/11/05
to
Brendan Eich aber hob zu reden an und schrieb:

Hey, that's good news!

<holdingmybreath> :)


Karsten

JFTR: no PM copy needed, I'm reading the groups I'm posting to.

0 new messages