Open Bug 1463064 Opened 7 years ago Updated 3 years ago

Misleading error message "Constructor HTMLElement requires 'new'"

Categories

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

60 Branch
defect

Tracking

()

UNCONFIRMED

People

(Reporter: mdn, Unassigned)

Details

(Keywords: dev-doc-needed)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Firefox/60.0 Build ID: 20180503143129 Steps to reproduce: Run this JavaScript: HTMLElement() Actual results: A TypeError is thrown with the message "Constructor HTMLElement requires 'new'". Expected results: new HTMLElement() throws a TypeError as well. The error message should rather say "Constructor HTMLElement cannot be invoked", or something alike.
Has STR: --- → yes
Component: Untriaged → Developer Tools: Console
OS: Unspecified → All
Hardware: Unspecified → All
Hello, thanks for reporting mdn ! The console is only the consumer of the message here, I suspect this bug should be in the JS engine module so the right person can pick this up. That being said, I'm seeing 2 different error messages if I omit or not the `new` keyword, and they both provide accurate information: -> HTMLElement() <- TypeError: Constructor HTMLElement requires 'new' -> new HTMLElement() <- TypeError: Illegal constructor.
Component: Developer Tools: Console → DOM
Product: Firefox → Core
Priority: -- → P3
Component: DOM → DOM: Core & HTML
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.