Summary: | appendChild for tr element to table element fails with DOM Exception HIERARCHY_REQUEST_ERR | ||
---|---|---|---|
Product: | [Applications] konqueror | Reporter: | Jos van den Oever <jos> |
Component: | kjs | Assignee: | Konqueror Developers <konq-bugs> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | openSUSE | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: | |||
Attachments: | demonstration of the javascript |
Description
Jos van den Oever
2005-05-13 10:13:07 UTC
Created attachment 11016 [details]
demonstration of the javascript
Ok, I just found a workaround. Instead of writing: table.appendChild(tr); One can write: var tbody = document.createElement('tbody'); table.appendChild(tbody); var tr = document.createElement('tr'); tbody.appendChild(tr); I'm not sure what the spec says about this, so I'm not really sure if this is a bug anymore. Since a table can have more than one tbody element, the Konqueror implementation is very strict, but not wrong. Therefore, the bug has been resolved. Actually it's wrong that something, which works in Mozilla and IE, doesn't work in Konq (KHTML). Someone else reported this on IRC, and I fixed it. SVN commit 417591 by dfaure: Allow javascript to insert a TR directly into a TABLE, creating a TBODY section if needed BUG: 105586 M +5 -0 ChangeLog M +13 -0 html/html_tableimpl.cpp M +1 -0 html/html_tableimpl.h --- trunk/KDE/kdelibs/khtml/ChangeLog #417590:417591 @@ -1,3 +1,8 @@ +2005-05-24 David Faure <faure@kde.org> + + * html/html_tableimpl.cpp (appendChild): Allow javascript to insert + a TR directly into a TABLE, creating a TBODY section if needed (bug #105586). + 2005-05-21 Harri Porten <porten@kde.org> * html/html_documentimpl.cpp: emit onload event even if the --- trunk/KDE/kdelibs/khtml/html/html_tableimpl.cpp #417590:417591 @@ -307,6 +307,19 @@ exceptioncode = DOMException::INDEX_SIZE_ERR; } +NodeImpl *HTMLTableElementImpl::appendChild(NodeImpl *child, int &exceptioncode) +{ + if(child->id() == ID_TR) { // #105586, allow to insert a TR inside a TABLE, creation section as needed + // See insertRow + if (!firstBody && !head && !foot && !hasChildNodes()) + setTBody( new HTMLTableSectionElementImpl(docPtr(), ID_TBODY, true /* implicit */) ); + Q_ASSERT( firstBody ); + if (firstBody) + return firstBody->appendChild( child, exceptioncode ); + } + return HTMLElementImpl::appendChild( child, exceptioncode ); +} + NodeImpl *HTMLTableElementImpl::addChild(NodeImpl *child) { #ifdef DEBUG_LAYOUT --- trunk/KDE/kdelibs/khtml/html/html_tableimpl.h #417590:417591 @@ -95,6 +95,7 @@ // overrides virtual NodeImpl *addChild(NodeImpl *child); + virtual NodeImpl *appendChild( NodeImpl *newChild, int &exceptioncode ); virtual void parseAttribute(AttributeImpl *attr); virtual void attach(); |