ブラウザ(およびJSDOM)のすべての要素をdocument.querySelectorAll
で取得したいと思います。document.querySelectorAllで未知の要素を取得する
私がチェックし、その後.toString
を使用して試した場合はそのようなHTMLUnknownElement
として要素レジスタ:
if (node.toString() === "[object HTMLUnknownElement]") ...
しかし、問題の要素の名前に-
などを持っている場合、これは動作しません。 <test-element>
。私はHTMLカスタム要素との互換性を前提としています。今、私は単に私が知っているすべてのタグの:not
年代の負荷を持つすべての要素をリストアップしていますが、これはハックのように感じている:document.querySelectorAll("*:not(html):not(head):not(link):not(meta):not(base):not(script):not(style):not(title):not(body):not(address):not(article):not(aside):not(footer):not(h1):not(h2):not(h3):not(h4):not(h5):not(h6):not(header):not(hgroup):not(nav):not(section):not(blockquote):not(cite):not(dd):not(dl):not(div):not(dt):not(figcaption):not(figure):not(hr):not(li):not(ol):not(ul):not(menu):not(main):not(p):not(pre):not(a):not(abbr):not(b):not(bdi):not(bdo):not(br):not(code):not(data):not(time):not(dfn):not(em):not(i):not(kbd):not(mark):not(q):not(rp):not(ruby):not(rt):not(rtc):not(rb):not(s):not(del):not(ins):not(samp):not(small):not(span):not(strong):not(sub):not(sup):not(u):not(var):not(wbr):not(area):not(map):not(audio):not(source):not(img):not(track):not(video):not(embed):not(object):not(param):not(picture):not(canvas):not(noscript):not(caption):not(table):not(col):not(colgroup):not(tbody):not(tr):not(td):not(tfoot):not(th):not(thead):not(button):not(datalist):not(option):not(fieldset):not(label):not(form):not(input):not(legend):not(meter):not(optgroup):not(select):not(output):not(progress):not(textarea):not(details):not(dialog):not(menuitem):not(summary):not(content):not(slot):not(element):not(shadow):not(template):not(acronym):not(applet):not(basefont):not(font):not(big):not(blink):not(center):not(command):not(dir):not(frame):not(frameset):not(image):not(isindex):not(keygen):not(listing):not(marquee):not(multicol):not(nextid):not(noembed):not(plaintext):not(spacer):not(strike):not(tt):not(xmp)")
は、誰もがより良い方法を知ってい
へこれを行う?これが役立つ
既知または未知として登録済みのカスタム要素を検討しますか? – str
[登録されたカスタム要素のリストを取得する方法](https://stackoverflow.com/questions/27334365/how-to-get-list-of-registered-custom-elements) – str
@str登録されるまで – Xenxier