JavaScript strings do not contain elements and their contents

RESOLVED INVALID

Status

()

Core
XSLT
RESOLVED INVALID
16 years ago
16 years ago

People

(Reporter: Inigo Surguy, Assigned: peterv)

Tracking

Trunk
x86
Windows 2000
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

(Reporter)

Description

16 years ago
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.1b) Gecko/20020814
BuildID:    2002081409


Elements and their contents are not being correctly copied into JavaScript
strings, only text nodes that are outside elements. This is not the case in
normal HTML.

For example, 
  alert("<xsl:call-template name="test1"/>");
  
  <xsl:template name="test2">before<h2>headingtext</h2>after</xsl:template>

produces "beforeafter" and misses the <h2> and the headingtext.

I've confirmed the correct behaviour in Xalan and in MSXML.

It's possible to workaround this bug with copious use of CDATA sections.

Reproducible: Always
Steps to Reproduce:
1. See attachments
(Reporter)

Comment 1

16 years ago
Created attachment 95303 [details]
Lots of alerts demonstrating bug
(Reporter)

Comment 2

16 years ago
Created attachment 95304 [details]
The XML file
You should not create childelements of a <script>. You should create the
resulting *tree* that you want, not the serialization that you want.

What happens is that you create a child h2-element of the script, when the
script then executes it just grabs all the text-children and concatinate those
and execute, childelements are ignored. Agreeably this is debateable if it is
the right behavious, we shold maybe just refuse to execute the script entierly.
The resulting output is not valid html so no spec defines the behaviour.

Compliments for a very nice way of attaching the testcase though!! I wish more
people would do it this way.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 16 years ago
Resolution: --- → INVALID
Summary: JavaScript strings do not contain elements and their contents → JavaScript strings do not contain elements and their contents
You need to log in before you can comment on or make changes to this bug.