Re: [w3c/webcomponents] The way to access current script or current root, from Shadow DOM (#717)

As @annevk 's https://github.com/w3c/webcomponents/issues/717#issuecomment-366505806, I don't think we revert the `document.currentScript` decision to return `null` for shadows.

If we pursue `currentRoot`, maybe implement `DocumentOrShadowRoot.currentRoot` and `DocumentOrShadowRoot.currentScript` and use the code
```js
function getCurrentScript() {
  var root = document;
  while (root != root.currentRoot)
    root = root.currentRoot;
  return root.currentScript;
}
```
which is a similar approach to `DocumentOrShadowRoot.activeElement`.

But similar to what @rniwa stated above, I feel reluctant to add new features to classic script.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/717#issuecomment-366943265

Received on Tuesday, 20 February 2018 11:06:37 UTC