If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

"Node was not found" WITHOUT .xhtml extension

RESOLVED INVALID

Status

()

Firefox
File Handling
--
major
RESOLVED INVALID
11 years ago
11 years ago

People

(Reporter: Trenton D. Adams, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

11 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0

This is a really odd bug.  The nodes do actually get found, but this error occurs when I try and call element.insertBefore() in javascript.  I've printed out the attributes for the refElement, thereby proving that it is actually getting the element, yet insertBefore() still complains.


Reproducible: Always

Steps to Reproduce:
1. Click the "Add Comment" link.

Actual Results:  
an error appears in the console as follows...
Error: uncaught exception: [Exception... "Node was not found"  code: "8" nsresult: "0x80530008 (NS_ERROR_DOM_NOT_FOUND_ERR)"  location: "file:///C:/Documents%20and%20Settings/trenta/Desktop/temp/APL%20Dispatcher.html Line: 46"]

Expected Results:  
A comment TR/TD/form/input should be added.  In the case where the file is named Something.xhtml, it works just fine.

Below is the w3c validated proof XHTML.  Save it as a .xhtml on the first try, and you will see that it works.  Save it as .html on the second try, and you will find that it does not work.  I would expect the browser to be getting the DOCTYPE from the DOCTYPE declaration, not the file extension.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Example Broken</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

    <script type="text/javascript">
function addComment(commentRowID, jobTableID)
{
    var commentTR;
    var jobTable;
    var newTR;
    var newTD;
    var newForm;
    var input;
    jobTable = document.getElementById(jobTableID);
    newTR = document.createElement("tr");

    newForm = document.createElement("form");

    input = document.createElement("input");
    input.name = "something";
    input.value ="enter your comment here";
    input.type = "text";
    input.className = "realtime_box";
    input.maxlength = "255";
    input.size = "50";
    newForm.appendChild(input)

    newTD = document.createElement("td");
    newTD.colSpan = '4';
    newTD.appendChild(newForm);
    newTR.appendChild(newTD);
    newTD = document.createElement("td");
    newTR.appendChild(newTD);

//    jobTable.replaceChild(newTR, commentTR);
//    jobTable.appendChild(newTR);
//    alert (commentTR.id);
//    commentTR.display = "none";
//    jobTable.removeChild(commentTR);
    commentTR = document.getElementById(commentRowID);
    jobTable.insertBefore(newTR, commentTR);
//    alert(jobTable.lastChild);
//    newTR = commentTR.cloneNode(true);
//    newTR.id = undefined;
//    jobTable.removeChild(commentTR);
//    jobTable.appendChild(newTR);
//    jobTable.appendChild(commentTR);
}
    </script>
    
  </head>
<body>
  <table class="special" id="job_328">
    <tr id="last_328" class="comments print_hidden">
      
      <td colspan="4" class="comment_list" align="center">

        <a href="javascript:addComment('last_328', 'job_328');">Add Comment</a>
      </td>
    </tr>
  </table>
</body>

</html>

Comment 1

11 years ago
Works for me when I set the .html as application/xhtml+xml on the web server.
I think the mimetype overriding the doctype is correct behaviour.
(Reporter)

Comment 2

11 years ago
Oh, that's a possibility.  I always assumed that the DOCTYPE was the be all end all of the document type.  Hmmm.

Ahhh, if that's the case, I guess I have to set my own content-type.  Because this is what it is setting...
Content-Type: text/html

Sorry about that.

(In reply to comment #1)
> Works for me when I set the .html as application/xhtml+xml on the web server.
> I think the mimetype overriding the doctype is correct behaviour.
> 

Comment 3

11 years ago
Marking as invalid per comment 2, assuming someone understands why the insertBefore call fails when the document is sent as text/html.  (My guess is that when the document is sent as text/html, the parser adds a TBODY element between the TABLE and TR elements, making it so the TR isn't a direct child of the TABLE.)
Status: UNCONFIRMED → RESOLVED
Last Resolved: 11 years ago
Resolution: --- → INVALID
(Reporter)

Comment 4

11 years ago
Very good guess.  Yes, it was adding a tbody, and it is now working, since I put in the correct content-type header.
You need to log in before you can comment on or make changes to this bug.