Using QWebElement::appendInside() on the QWebElement representing the HTML's <head> tag does nothing. e.g. this works: QWebElement e=frame->findFirstElement("body"); e.appendInside("<p>test test test</p>"); But this doesn't: QWebElement e=frame->findFirstElement("head"); e.appendInside("<script type=\"text/javascript\" src=\"test.js\"/>");
Created attachment 73230 [details] Test case Adding simple test case. FWIW this is with the QtWebKit in the current qt 4.7 branch
Initial assessment: HTMLElement::deprecatedCreateContextualFragment() explicitly check if the element is a HEAD element (among others) and does not create a DocumentFragment if that's the case. Explicitly calling Element::deprecatedCreateContextualFragment() instead makes this work. Not sure yet if this is a Qt documentation issue or an actual bug.
(In reply to comment #2) > Not sure yet if this is a Qt documentation issue or an actual bug. I think we can consider this as a bug. To create WebKit animation on the fly it can be usefull to add stuff in the <head> element. If this can be supported, that sounds like a nice feature to have. I give this a low priority.
Created attachment 74518 [details] Patch
Comment on attachment 74518 [details] Patch Needs an autotest in WebKit/qt/tests/qwebelement
Created attachment 74528 [details] Patch
Comment on attachment 74528 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=74528&action=review > WebKit/qt/Api/qwebelement.cpp:1030 > + RefPtr<DocumentFragment> fragment; > HTMLElement* htmlElement = static_cast<HTMLElement*>(m_element); > - RefPtr<DocumentFragment> fragment = htmlElement->deprecatedCreateContextualFragment(markup); > + if (htmlElement->hasLocalName(HTMLNames::headTag)) > + fragment = htmlElement->Element::deprecatedCreateContextualFragment(markup); > + else > + fragment = htmlElement->deprecatedCreateContextualFragment(markup); > > ExceptionCode exception = 0; Why not just cast it to Element always?
(In reply to comment #7) > Why not just cast it to Element always? Good point. For some reason I thought the default action should be to go through HTMLElement but there's no need for that it seems. I'll upload a new patch.
Created attachment 74533 [details] Patch
Comment on attachment 74533 [details] Patch Clearing flags on attachment: 74533 Committed r72510: <http://trac.webkit.org/changeset/72510>
All reviewed patches have been landed. Closing bug.