I do have a two xbl-elements ("fileview_breadcrumbs" and
"fileview_breadcrumbs_item") declared in the same file.
"fileview_breadcrumbs" has a method named "fillMe" that appends newly
created elements of type "fileview_breadcrumbs_item" to itself.
Reduced to the basics it looks like this:
<method name="fillMe">
<body>
<![CDATA[
var parts = this.someFunctionThatReturnsAnArray();
// add the new children
for(var i = 0; i < parts.length; ++i)
{
var breadItem = this.ownerDocument.createElement
("fileview_breadcrumbs_item");
this.appendChild(breadItem);
breadItem.fileGroupItem = parts[i]; // *highlighted*
}
]]>
</body>
</method>
---------------------------------------------------
I am adding a "fileview_breadcrumbs" element to Firefox's main-window
using an overlay. I am also adding a EventListener to the tabbrowser
that listens to the "DOMContentLoaded" event. Whenever my listener is
called, I will call the "fillMe"-method of the "fileview_breadcrumbs"
element that I added via the overlay.
Everything works well all the time, except for the first time it
happens as Firefox starts up and loads the last page that was opened,
when I closed Firefox the last time.
This first time "fillMe" is called, the fileGroupItem is never set
(see the *highlighted* line). I tested it through, and I can't even
access fields that have default-values, thus I am pretty sure the
binding is not attached to the newly created elements. This is weird,
as I add them to the document, before accessing them. Also, if I place
an alert before the creation, everything is created correctly, thus I
guess it is something asynchronous again, but it can't be the CSS, as
the binding rules are in the same file. I also checked it using the
computed style (.MozBinding) and it was correct.
So. Any ideas what prevents the binding from being attached?
Thanks a lot!
Cheers.
As I already said, the "fileview_breadcrumbs"-element is in a panel/
overlay. Whenever I call fillMe before the panel has been opened ONCE,
the "fileview_breadcrumbs_item"'s that I create in there, won't get
their binding attached correctly. Well, they do somehow, as their
"constructor"-method is called, but no other method or property will
work.
I then tested creating normal buttons and setting their label. before
having opened the panel once, the buttons will have NO labels - so the
problem isn't connected to my "fileview_breadcrumbs_item" binding.
So this confuses me even more. As I am able to call "fillMe", the
content of the panel has obviously been correctly created before
opening the panel, but still it can't correctly create any elements.
You can test it with the following code for the "Edit this bookmark"-
Panel (the one that pops up when you click the star in the address-
bar):
var bookmarkpanelcontent = document.getElementById
("editBookmarkPanelContent");
var aButton = document.createElement("button");
bookmarkpanelcontent.appendChild(aButton);
aButton.label = "I am the new button";
Run this code before opening the panel, then click on the star and you
will have a button with no label. Contrary to my setup which will only
do this for the first time before the popup has been opened, this code
will always create buttons, that have no label (except you have the
panel opened with noautohide being true [using setAttribute]).
So, I am pretty sure, this is a panel/xbl-bug or I missed some
information about adding elements to panels that have not been opened
yet.
Can someone confirm this?
Thanks!
>So, I am pretty sure, this is a panel/xbl-bug or I missed some information about adding elements to panels that have not been opened yet.
>
>
I don't know about panels, but XBL1 has a limitation that it is only
applied in two circumstances: a) when the element needs to be displayed
(e.g. painted, or possibly to have its size calculated) or b) the first
time the element is seen by script (and the element must already be in
the document, so this excludes elements created by script). Before the
XBL is applied all you see is a regular XUL element with only the basic
properties listed in nsIXULElement.idl (and its ancestors).
--
Warning: May contain traces of nuts.