zinas / the-90s-polyfil

Only a true visionary could think about using one of the most modern tools the web platform offers, to re-create some of the most horrific things ever created
92 stars 4 forks source link

Use document.currentScript.ownerDocument #3

Open warpech opened 10 years ago

warpech commented 10 years ago

In nineties-under-construction.html, I noticed that a hack is used to access the imported document:

var ucImport = document.querySelector('link[href*=under-construction]').import;

This doesn't work for me when an import is requested from another import.

Would you consider replacing it with this snippet that works in such case and is recommented by the Polymer team:

var ucImport;
if (document._currentScript) {
  //@see http://www.polymer-project.org/platform/html-imports.html
  //@see https://groups.google.com/d/topic/polymer-dev/4UKty9tb1-s/discussion 
  ucImport = document._currentScript.ownerDocument;
}
else {
  ucImport = document.currentScript.ownerDocument;
}

Great job btw! Funny and teaching at the same time.