javascript - querySelector not selecting class -
i have electron app , within index.html file, import number of html files in <head> so:
<link rel="import" href="settings.html"> <link rel="import" href="dashboard.html"> <link rel="import" href="locker.html"> for now, each file same, different header, , follows same template:
<template class="section-template"> <section id="locker" class="wrapper"> <div class="inner"> <h3>locker</h3> </div> </section> </template> in javascript have following function triggers on page load:
console.log(`importing dom`); const links = document.queryselectorall('link[rel="import"]') array.prototype.foreach.call(links, function(link){ var content = link.import; var el = content.queryselector('.section-template'); console.log(el); }) this selecting imported files, calling them , should selecting whole file based on section-template class.
for reason, el null , cannot figure out why. logging out content shows this. not sure why content appearing in <head>, though think part of issue http://imgur.com/a/612c8
i've copied html of locker.html file jsfiddle, , ran javascript on document works fine.
a little confused why isn't working.
update: example how should work here under imports https://www.html5rocks.com/en/tutorials/webcomponents/imports/
Comments
Post a Comment