SourceForge has been redesigned. Learn more.
Close

#101 unable to set attribute after insert an element on innertext

open
nobody
None
5
2014-10-22
2012-03-16
Ian
No

I ripped my hair out trying to figure this out. Originally I thought it was a reference problem, but not at all, it's actually because I was inserting an element on innertext.

    // make sure caption exists
    if ( ! $table->find("caption", 0))
    {
        $table->innertext = "<caption><!-- insert caption --></caption>".$table->innertext; // causes problems setting attributes after this point

// $table->first_child()->outertext = "".$table->first_child()->outertext; // workaround
}

    foreach ($table->find('tr') as $tr)
    {
        $tr->bgcolor = NULL;
        remove_classes($tr, array('tablecolor', 'widget'));
    }

I found the best workaround was to get the first child and insert on the outertext of that element, as described in the API.

However, my intuition told me that it wouldn't be a problem to insert an element on innertext and I believe this should at least be documented.

Discussion


Log in to post a comment.