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

Error with push/replace State DOMException in iframe with data:text/html #495

Closed
steffanhalvorsen opened this issue Sep 25, 2020 · 1 comment

Comments

@steffanhalvorsen
Copy link

steffanhalvorsen commented Sep 25, 2020

Version

4.0.0-beta.12

Reproduction link

https://jsfiddle.net/9tvd4hw6/ (simple example - not working using vue & vue-router next)
https://jsfiddle.net/z9qsbrLh/2/ (advanced - not working using vue & vue-router next)
https://jsfiddle.net/yor1f3q0/1/ (working example using vue next without vue-router next)
https://jsfiddle.net/o5zL7sm4/ (working example using vue 2 & vue router 3)

Steps to reproduce

  • Create a simple vue app inside a variable as a string with minimal VueRouter setup using CDN
  • Ex. var myVueNextCodeWithRouter = <script src="unpkg.com/..."/><div id="app#>...</div><router-link to=".../>...<script/>...
  • Store code in a variable using: var codeForIframe = 'data:text/html' + myVueNextCodeWithRouter;
  • Append code as src to an iframe
<iframe id="hey"></iframe>
<script>
let code = 'data:text/html,' + encodeURIComponent(`
<script src="https://unpkg.com/vue@3.0.0/dist/vue.global.js"></` + `script>
<script src="https://unpkg.com/vue-router@4.0.0-beta.12/dist/vue-router.global.js"></` + `script>
<div id="app">
  <p>
    <router-link to="/">Go to Home</router-link>
    <router-link to="/about">Go to About</router-link>
  </p>
  <router-view></router-view>
</div>
<script>
const Home = { template: '<div>Home</div>' }
const About = { template: '<div>About</div>' }

const routes = [
  { path: '/', component: Home },
  { path: '/about', component: About },
]

const router = VueRouter.createRouter({
  history: VueRouter.createWebHashHistory(),
  routes
})

const app = Vue.createApp({})
app.use(router)

app.mount('#app')
</` + `script>
`);
let iframe = document.getElementById('hey')
iframe.src = code
</script>

What is expected?

It should run the app in iframe with routing

What is actually happening?

It throws a warning, destroys the render process and displays the source code instead.


The app works fine in iframe using vue next without next VueRouter: https://jsfiddle.net/yor1f3q0/1/
It does also work with VueRouter v3 for both History and Hash mode: https://jsfiddle.net/o5zL7sm4/
This render method is used to isolate a Vue App in an iframe with source code reactivity for working with Vue Components with Visual editing of Vue components.

Skjermbilde 2020-09-26 kl  01 24 24

@posva posva closed this as completed in 2a14c19 Sep 26, 2020
@posva
Copy link
Member

posva commented Sep 26, 2020

Thank you!

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

2 participants