Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document.currentScript is not defined when executing in scope="none" #10

Open
sashafirsov opened this issue Nov 1, 2018 · 4 comments
Open

Comments

@sashafirsov
Copy link
Member

sashafirsov commented Nov 1, 2018

For microapplication concept it is crucial to have an embedded script serving and accessing the content directly around the script without the need to identify the surrounding DOM. I.e. ability to traverse DOM starting from current script. The way around like dom identified with ID unfortunately is not universal as it could be multiple microapplications ( including same type ) presented on same host page. The dom insulation is not always applicable as scope=none disables insulation.

The cause of currentScript is not defined is in dynamic script loading. Under standard only scripts which are part of initial HTML will be given document.curentScript set.

@sashafirsov
Copy link
Member Author

whatwg/html#1013
states the interest for currentScript availability in shadowDom.

@sashafirsov
Copy link
Member Author

Work around: plug-in to module loader (xhr/workers/etc) and define the alternative variable in document scope. document.currentModule with SCRIPT object, for ES6 modules the parentNode would refer to parent module, question is how to associate the instance and module since the actual use is to get the HtmlElement instance reference from module. I.e. get current script or ownerElement in order to access other elements within shadowDom.

@sashafirsov
Copy link
Member Author

In embed-page document.epaCurrentScript will serve as surrogate.

@sashafirsov
Copy link
Member Author

#11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant