I am developing an Electron app, in which the index.html imports a search.html:
<link rel="import" href="search.html">
And inside the search.html, I create a button whose id is searchBtn.
Then, in the redenerer.js, I try to get the searchBtn:
var link = document.querySelector('link[rel="import"][href="search.html"]');
var content = link.import.querySelector('template');
console.log(content);
var searchBtn = content.querySelector('#searchBtn');
console.log(searchBtn);
The output of the first log is expected, but the second log for searchBtn is always null.
Is there any wrong with my code? If so, how to obtain the element in template html correctly?
The output is following:
I notice that there is a document-fragment inside the template.

contentis thetemplate, in which there is adocument-fragment.