Closed Bug 1448110 Opened 6 years ago Closed 6 years ago

DOMParser - Importing elements from parsed document

Categories

(Core :: DOM: Core & HTML, defect)

59 Branch
x86_64
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: pnparam, Unassigned)

Details

(Keywords: dom1, dom2)

Attachments

(1 file)

Attached file Test Scenarios
User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0
Build ID: 20180315233128

Steps to reproduce:

I am creating a template engine for my application. A sample is attached.



Actual results:

While using XML Dom parsing of string and appending on main document element, the default browser styles are not getting applied on elements. Not even displaying the input tag properly.
While using HTML Dom parsing of string and appending on main document element, tr/td elements are vanished - but instead a text node with its content is getting created on parsing.


Expected results:

When using XML Dom parsing method, at least when importNode is called, the default browser styles should be applied on the node.
When using HTML Dom parsing, the tr/td tags should be persisted as it is, even if there is no holding table present in the document.
Keywords: dom1, dom2
OS: Unspecified → Windows 7
Hardware: Unspecified → x86_64
Component: Untriaged → DOM: Core & HTML
Product: Firefox → Core
Summary: import xml node → DOMParser - Importing elements from parsed document
when you parse XML, you need to define namespace for the elements.

And for HTML parsing, I'm pretty sure we just do 
what https://html.spec.whatwg.org/multipage/parsing.html#parsing says.
(In reply to Olli Pettay [:smaug] (only webcomponents and event handling reviews, please) from comment #1)
> when you parse XML, you need to define namespace for the elements.
> 
> And for HTML parsing, I'm pretty sure we just do 
> what https://html.spec.whatwg.org/multipage/parsing.html#parsing says.

That is what I think I was missing - the namespace.
When I changed my template declaration to:
<tpl xmlns="http://www.w3.org/1999/xhtml">
instead of just:
<tpl>
The XML parsing methods works very well. Thanks for the fast response and help. Really appreciate it. I will close the bug report as my question is invalid based on this.
Status: UNCONFIRMED → RESOLVED
Closed: 6 years ago
Resolution: --- → INVALID
(In reply to Olli Pettay [:smaug] (only webcomponents and event handling reviews, please) from comment #1)
> when you parse XML, you need to define namespace for the elements.
> 
> And for HTML parsing, I'm pretty sure we just do 
> what https://html.spec.whatwg.org/multipage/parsing.html#parsing says.

It is nice if it is possible to adopt the importing document's XML Namespace by default if we use the document importNode/adoptNode methods to copy/move elements from other documents.

Please re-open if this is a valid suggestion/issue, or tell me if I need to create another ticket for this.

Thanks in Advance!
Flags: needinfo?(bugs)
(In reply to pnparam from comment #3)

> It is nice if it is possible to adopt the importing document's XML Namespace
> by default if we use the document importNode/adoptNode methods to copy/move
> elements from other documents.

Not sure I understand this. Namespace is a property of an Element (or Attr). 
Are you suggesting there should be a way to change the namespace when importing nodes?
That would change the semantics of some elements totally.
Flags: needinfo?(bugs)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: