New issue
Advanced search Search tips

Issue 807514 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Jan 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug

Blocking:
issue 648828



Sign in to add a comment

document.createElement in SVG documents should not create custom elements

Project Member Reported by tkent@chromium.org, Jan 31 2018

Issue description

Chrome Version: ToT
OS: All but iOS

What steps will reproduce the problem?
(1) In <script> in an SVG document, run the following code:

  class MyElement1 extends HTMLElement {}
  customElements.define('my-element', MyElement1);
  let element = document.createElement('my-element', {});
  alert(element instanceof MyElement1);

  class MyElement2 extends HTMLDivElement {}
  customElements.define('my-div', MyElement2, { extends: 'div' });
  element = document.createElement('div', { is: 'my-div' });
  alert(element instanceof MyElement2);

What is the expected result?
Two alert dialogs with "false"

What happens instead?
Two alert dialogs with "true"

Please use labels and text to provide additional information.
Our Document::creteElement(local_name, string_or_options, exception_state) doesn't have a check for HTML-lie document.  i.e. "IsXHTMLDocument() || IsHTMLDocument()"

Firefox works correctly.
 
Project Member

Comment 1 by bugdroid1@chromium.org, Jan 31 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/91707a70383a6714ad5dc1b8a4096ee83755a5b5

commit 91707a70383a6714ad5dc1b8a4096ee83755a5b5
Author: Kent Tamura <tkent@chromium.org>
Date: Wed Jan 31 07:20:18 2018

custom-elements: document.createElement in SVG documents should not create custom elements.

createElement() should assume the namespace is XHTML only if the
document is HTML-like.

New behavior matches to the standard and Firefox.

Bug:  807514 
Change-Id: I1164612b6512c94de96bdefbf053e8f132f8b9f7
Reviewed-on: https://chromium-review.googlesource.com/894749
Commit-Queue: Kent Tamura <tkent@chromium.org>
Reviewed-by: Dominic Cooney <dominicc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533221}
[add] https://crrev.com/91707a70383a6714ad5dc1b8a4096ee83755a5b5/third_party/WebKit/LayoutTests/external/wpt/custom-elements/Document-createElement-svg.svg
[modify] https://crrev.com/91707a70383a6714ad5dc1b8a4096ee83755a5b5/third_party/WebKit/Source/core/dom/Document.cpp
[modify] https://crrev.com/91707a70383a6714ad5dc1b8a4096ee83755a5b5/third_party/WebKit/Source/core/html/custom/CustomElement.cpp
[modify] https://crrev.com/91707a70383a6714ad5dc1b8a4096ee83755a5b5/third_party/WebKit/Source/core/html/custom/CustomElement.h

Comment 2 by tkent@chromium.org, Jan 31 2018

Status: Fixed (was: Started)

Sign in to add a comment