Re: Insertbefore - c++ success and then failure
| Newsgroups | gmane.comp.mozilla.devel.dom |
|---|---|
| Organization | http://groups.google.com |
| Message-ID | <d68d67db-bb54-4f62-a98c-daa3dc568e87@d36g2000prf.googlegroups.com> |
On Nov 11, 11:37 am, Boris Zbarsky <[email protected]> wrote: > [email protected] wrote: > > There seems to be no difference between the successful and failed > > except the way the element was found. The successful insert is > > inserting before an element just added to the DOM, the failed is > > inserting before an already existing element. > > Just added to the dom _where_? Already existing _where_? > > > i = domDoc->InsertBefore(ielement, ielement2, > > getter_AddRefs(dnode2)); > > The object you call InsertBefore on should be the parent of ielement2. > Clearly that's not the case here. I suspect that it's not true in any > of your other calls either. > > Of course all this is documented in the DOM spec. > > -Boris > Just added to the dom _where_? Already existing _where_? The base HTML had RACEOTHR already existing and the input was just added in previous code not posted. Anyway, what and how much to put into code snippets is always a question. However, I did retrieve the parent of dnode just using dnode- >GetParentNode and used that, it worked. The immediate parent of the other input field which was successful would have to be htmlform. In that case I had appended child directly to htmlform. I assume that's why it worked b/c htmlform was the direct parent. In dnode's case I made the same assumption. Thanks for your help, it got me to try a couple other things and worked. Yes, I read the DOM docs on insert. Seriously JS examples that are shown don't help with gecko. Maybe there's a better way, but all my success from gecko/c++ comes via head-banging and code-slinging. Unfortunate but I exhaust any docs and examples pretty quick. It's pretty much trial and error and post a question or two. Judging by the emails I get privately on some of my Gecko questions it's a shared reality. I spend many hours banging and testing code but sometimes I get to the wall so I post. Maybe it was obvious but I'm not a DOM node expert just yet. I do really appreciate your help, thanks.