googlearchive / IMD

An AMD-compatible module registry for use with HTML Imports
73 stars 24 forks source link

Aliasing with `as` attribute doesn't work in Firefox and Safari #8

Closed antonmoiseev closed 8 years ago

antonmoiseev commented 9 years ago

document.currentScript doesn't contain as attribute while inferring module ID:

function _inferModuleId() {
  var script = document.currentScript;
  if (script.hasAttribute('as')) { // Always `false`in Firefox and Safari
    return script.getAttribute('as');
  }
  //...
antonmoiseev commented 9 years ago

Here is a small demo app. The problem is reproducible only within HTML Imports. According to the polyfill docs document._currentScript should be used within the browsers without native HTML Imports support. Looks like it fixes the problem, please see README.md of the demo app.