Comments (2)
Instead of using the document.write
api which has been removed by Google, we can use service worker
to thoroughly handle this.
from repl.
Thank you @tachibana-shin for drawing my attention to this. I did find what you refer to: https://developer.chrome.com/blog/removing-document-write
However, I believe this does not apply to our case:
Specifically Chrome will not execute the <script> elements injected via document.write() when all of the following conditions are met:
...
2. The document.write() is in a top level document. The intervention does not apply to document.written scripts within iframes as they don't block the rendering of the main page.
...
In this case we execute document.write
in the iframe, so we are good to go.
Note that document.write
triggers page events like load
and DOMContentLoaded
. So users can use these as usual.
This is a much simpler solution than having to manage and maintain a service worker for the output page. In addition, using a service worker will require injecting code that handles it in user code, which is something we should aim to avoid if we can.
Anyway, regardless of the way we send the code, I think the main goal is to properly sandbox the iframe by keeping the page on a separate origin.
from repl.
Related Issues (20)
- repl组件的.left .right .wrapper与vitepress中的类名重复,导致样式错乱 HOT 1
- Support custom loading typeScript path
- Suggestion: Support layout reverse HOT 2
- store.setImportMap doesn't work in VitePress HOT 3
- Can't find the definition of package without .d.ts file in itemself
- How can I add extra lib to current monaco editor? HOT 1
- 在组件中正确引入cesium 可以渲染但是没有出现预期中的地球 HOT 1
- Unable to properly showcase the effect of Cesium in the repl HOT 1
- Showoutput argument not working HOT 2
- Import the complete dependency package HOT 3
- S
- Expect to support template file configuration
- Suggest using chobitsu to do devtools HOT 2
- No way to save importmap scopes
- Async component not supported
- VUE-CLI with REPL 3.4.x HOT 1
- Document breaking changes in v4 and fix the readme HOT 6
- Uncaught (in promise) TypeError: Object(...) is not a function at setup (vue-repl.js:16821:1) HOT 3
- [bug]if activeFile !== mainFile, mainFile would not compile HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from repl.