If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

document.getAnonymousNodes(this) returned null when the binding is in a custom namespace

RESOLVED INVALID

Status

()

Core
XBL
RESOLVED INVALID
11 years ago
11 years ago

People

(Reporter: Henry Li, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(3 attachments, 2 obsolete attachments)

(Reporter)

Description

11 years ago
User-Agent:       Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; (R1 1.5); .NET CLR 2.0.50727)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3

If the binding is declared in a custom namespace, the method document.getAnonymousNodes(this) returns null. This forces one to use the xul or html namespace only for xbl defined components.

Reproducible: Always

Steps to Reproduce:
1. Create a binding using xbl in which make use of the function document.getAnonymousNodes(this) (e.g., in the constructor, add a line to alert the result to make sure that it is not null).

2. Create a stylesheet (name it mytag.css) to define bind a tag to the binding like the following
@namespace myns url(http://my.namespace.com/custom);

myns|mytag {
  -moz-binding: url('mytag.xml#mytag');
}

3. Use the custom tag in a page like the below:
<?xml version="1.0"?>
<?xml-stylesheet href="mytag.css" type="text/css"?>

<xul:window
  xmlns:myns="http://my.namespace.com/custom"
  xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<mytag>
</mytag>
</xul:window>

4. Try access the newly created xul page.
Actual Results:  
The alert for the result of document.getAnonymousNodes(this) returns null.

Expected Results:  
returns the children of the <content> tag in an array

Would a fuction like document.getAnonymousNodesNS(aNamespaceURL, this) help in solving this?
(Reporter)

Comment 1

11 years ago
Step 3 above should look like this:

<?xml version="1.0"?>
<?xml-stylesheet href="mytag.css" type="text/css"?>

<xul:window
  xmlns:myns="http://my.namespace.com/custom"
  xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<myns:mytag>
</myns:mytag>
</xul:window>

Comment 2

11 years ago
Could you please upload a testcase using "Add an attachment"
Yeah, please do upload a testcase.  This should work.
(Reporter)

Comment 4

11 years ago
Created attachment 264576 [details]
The XBL file

This is the xbl file I'm working on. It is a working component - composed of a left list a right list box and a couple of move buttons in the middle. The buttons are used to move items between the left and right list boxes. I added an alert in the getter method for the twinboxes property to check for null. The css file and a test.xul file will be uploaded next.
(Reporter)

Comment 5

11 years ago
Created attachment 264577 [details]
The binding css file for twinbox.xml
(Reporter)

Comment 6

11 years ago
Created attachment 264578 [details]
The xul file for testing
Created attachment 264580 [details]
CSS pointing to the attached XBL
Created attachment 264581 [details]
XUL pointing to the updated CSS
Attachment #264577 - Attachment is obsolete: true
Attachment #264578 - Attachment is obsolete: true
I see.  Your bound element has child nodes with no insertion points in the binding (the text node children, to be precise).  When this happens, XBL doesn't install anonymous content.  This is documented at http://developer.mozilla.org/en/docs/XBL:XBL_1.0_Reference:Anonymous_Content#Rules_for_Generation paragraph, 3, for example.  Generally, one adds a catch-all insertion point inside a display:none parent to prevent this from being a problem.

This doesn't happen with XUL because the XUL content sink strips out whitespace-only text children of all XUL nodes other than <xul:label> and <xul:description>.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 11 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.