Unknown Elements vs Undefined Custom Elements

ๆณจๆ„๏ผš

  • ๆฒ’ๆœ‰ "-" ็š„ๆจ™็ฑค (ๅฆ‚๏ผš<nosuchtag>) ๆœƒ่ขซ่ฆ–็‚บ HTMLUnknownElement๏ผŒ

  • ไฝ†ๆœ‰ "-" ็š„ๆจ™็ฑค (ๅฆ‚๏ผš<undefined-element>) ๆœƒ่ขซ่ฆ–็‚บ HTMLElementโ—๏ธ

const {log} = console;

[
    // <tabs> is an "unknown" element
    tag('tabs') instanceof HTMLUnknownElement,      // true

    // <x-tabs> is an "undefined" custom element
    tag('x-tabs') instanceof HTMLElement,           // true

].forEach(x => log(x));

// helper function
function tag(name){
    return document.createElement(name);
}

Last updated