<a href="/"><< Back to Homepage</a>
<hr />
- <div id="app">
- <section class="info">
- Name:
- <pre id="name">{{ route.name }}</pre>
- </section>
-
- <section class="info">
- Params:
- <pre id="params">{{ route.params }}</pre>
- </section>
-
- <section class="info">
- Query:
- <pre id="query">{{ route.query }}</pre>
- </section>
-
- <section class="info">
- Hash:
- <pre id="hash">{{ route.hash }}</pre>
- </section>
-
- <section class="info">
- FullPath:
- <pre id="fullPath">{{ route.fullPath }}</pre>
- </section>
-
- <section class="info">
- path:
- <pre id="path">{{ route.path }}</pre>
- </section>
-
- <hr />
-
- <ul>
- <li><router-link to="/">/</router-link></li>
- <li>
- <router-link to="/documents/%E2%82%AC"
- >/documents/%E2%82%AC</router-link
- >
- </li>
- <li>
- <router-link :to="{ name: 'docs', params: { id: '€uro' }}"
- >/documents/€uro (object)</router-link
- >
- </li>
- <li>
- <router-link
- :to="{ name: 'home', query: { currency: '€uro', 'é': 'e' }}"
- >/?currency=€uro&é=e (object)</router-link
- >
- </li>
- <li>
- <a href="/encoding/documents/%E2%82%AC"
- >/documents/%E2%82%AC (force reload)</a
- >
- </li>
- <li>
- <a href="/encoding/documents/€"
- >/documents/€ (force reload. not valid but should not crash the
- router)</a
- >
- </li>
- </ul>
-
- <router-view></router-view>
- </div>
+ <main id="app"></main>
</body>
</html>
const route = useRoute()
return { route }
},
+
+ template: `
+ <div id="app">
+ <section class="info">
+ Name:
+ <pre id="name">{{ route.name }}</pre>
+ </section>
+
+ <section class="info">
+ Params:
+ <pre id="params">{{ route.params }}</pre>
+ </section>
+
+ <section class="info">
+ Query:
+ <pre id="query">{{ route.query }}</pre>
+ </section>
+
+ <section class="info">
+ Hash:
+ <pre id="hash">{{ route.hash }}</pre>
+ </section>
+
+ <section class="info">
+ FullPath:
+ <pre id="fullPath">{{ route.fullPath }}</pre>
+ </section>
+
+ <section class="info">
+ path:
+ <pre id="path">{{ route.path }}</pre>
+ </section>
+
+ <hr />
+
+ <ul>
+ <li><router-link to="/">/</router-link></li>
+ <li>
+ <router-link to="/documents/%E2%82%AC"
+ >/documents/%E2%82%AC</router-link
+ >
+ </li>
+ <li>
+ <router-link :to="{ name: 'docs', params: { id: '€uro' }}"
+ >/documents/€uro (object)</router-link
+ >
+ </li>
+ <li>
+ <router-link
+ :to="{ name: 'home', query: { currency: '€uro', 'é': 'e' }}"
+ >/?currency=€uro&é=e (object)</router-link
+ >
+ </li>
+ <li>
+ <a href="/encoding/documents/%E2%82%AC"
+ >/documents/%E2%82%AC (force reload)</a
+ >
+ </li>
+ <li>
+ <a href="/encoding/documents/€"
+ >/documents/€ (force reload. not valid but should not crash the
+ router)</a
+ >
+ </li>
+ </ul>
+
+ <router-view></router-view>
+ </div>
+ `,
})
app.use(router)
<a href="/"><< Back to Homepage</a>
<hr />
- <div id="app">
- <ul>
- <li><router-link to="/">/</router-link></li>
- <li><router-link to="/foo">/foo</router-link></li>
- <li><router-link to="/bar">/bar</router-link></li>
- <li><router-link :to="{ name: 'encoded' }">/n/é</router-link></li>
- <li><router-link to="/unicode/é">/unicode/é</router-link></li>
- <li>
- <router-link :to="{ name: 'unicode', params: { id: 'é' }}"
- >/unicode/é (correctly encoded)</router-link
- >
- </li>
- <li>
- <router-link :to="{ path: '/', query: { t: 'é', 'é': 'e' }}"
- >/?currency=€uro&é=e (object)</router-link
- >
- </li>
- <li>
- <a href="/hash/#/unicode/%E2%82%AC"
- >/unicode/%E2%82%AC (force reload)</a
- >
- </li>
- <li>
- <a href="/hash/#/unicode/€"
- >/unicode/€ (force reload. not valid but should not crash the
- router)</a
- >
- </li>
- </ul>
-
- <p>
- path: <code id="path">{{ route.path }}</code>
- <br />
- query.t: <code id="query-t">{{ route.query.t }}</code>
- <br />
- hash: <code id="hash">{{ route.hash }}</code>
- </p>
-
- <router-view></router-view>
- </div>
+ <main id="app"></main>
</body>
</html>
const route = useRoute()
return { route }
},
+
+ template: `
+ <div id="app">
+ <ul>
+ <li><router-link to="/">/</router-link></li>
+ <li><router-link to="/foo">/foo</router-link></li>
+ <li><router-link to="/bar">/bar</router-link></li>
+ <li><router-link :to="{ name: 'encoded' }">/n/é</router-link></li>
+ <li><router-link to="/unicode/é">/unicode/é</router-link></li>
+ <li>
+ <router-link :to="{ name: 'unicode', params: { id: 'é' }}"
+ >/unicode/é (correctly encoded)</router-link
+ >
+ </li>
+ <li>
+ <router-link :to="{ path: '/', query: { t: 'é', 'é': 'e' }}"
+ >/?currency=€uro&é=e (object)</router-link
+ >
+ </li>
+ <li>
+ <a href="/hash/#/unicode/%E2%82%AC"
+ >/unicode/%E2%82%AC (force reload)</a
+ >
+ </li>
+ <li>
+ <a href="/hash/#/unicode/€"
+ >/unicode/€ (force reload. not valid but should not crash the
+ router)</a
+ >
+ </li>
+ </ul>
+
+ <p>
+ path: <code id="path">{{ route.path }}</code>
+ <br />
+ query.t: <code id="query-t">{{ route.query.t }}</code>
+ <br />
+ hash: <code id="hash">{{ route.hash }}</code>
+ </p>
+
+ <router-view></router-view>
+ </div>
+ `,
})
app.use(router)
<a href="/"><< Back to Homepage</a>
<hr />
- <div id="app">
- <component :is="ViewComponent"></component>
- </div>
+ <main id="app"></main>
</body>
</html>
return { route, ViewComponent, historyState, ...toRefs(route) }
},
+
+ template: `
+ <div id="app">
+ <component :is="ViewComponent"></component>
+ </div>
+ `,
})
app.use(router)
<a href="/"><< Back to Homepage</a>
<hr />
- <div id="app">
- <ul>
- <li>
- <router-link to="/">/</router-link>
- </li>
- <li>
- <router-link to="/cant-leave">/cant-leave</router-link>
- </li>
- </ul>
-
- <router-view></router-view>
- </div>
+ <main id="app"></main>
</body>
</html>
],
})
-const app = createApp({})
+const app = createApp({
+ template: `
+ <div id="app">
+ <ul>
+ <li>
+ <router-link to="/">/</router-link>
+ </li>
+ <li>
+ <router-link to="/cant-leave">/cant-leave</router-link>
+ </li>
+ </ul>
+
+ <router-view></router-view>
+ </div>
+ `,
+})
app.use(router)
window.vm = app.mount('#app')
<a href="/"><< Back to Homepage</a>
<hr />
- <div id="app">
- <h1>Scroll Behavior</h1>
- <ul>
- <li><router-link to="/">/</router-link></li>
- <li><router-link to="/foo">/foo</router-link></li>
- <li><router-link to="/bar">/bar</router-link></li>
- <li><router-link to="/bar#anchor">/bar#anchor</router-link></li>
- <li><router-link to="/bar#anchor2">/bar#anchor2</router-link></li>
- <li><router-link to="/bar#1number">/bar#1number</router-link></li>
- </ul>
- <transition
- name="fade"
- mode="out-in"
- @before-enter="flushWaiter"
- @before-leave="setupWaiter"
- >
- <router-view class="view"></router-view>
- </transition>
- </div>
+ <main id="app"></main>
</body>
</html>
setupWaiter: scrollWaiter.add,
}
},
+
+ template: `
+ <div id="app">
+ <h1>Scroll Behavior</h1>
+ <ul>
+ <li><router-link to="/">/</router-link></li>
+ <li><router-link to="/foo">/foo</router-link></li>
+ <li><router-link to="/bar">/bar</router-link></li>
+ <li><router-link to="/bar#anchor">/bar#anchor</router-link></li>
+ <li><router-link to="/bar#anchor2">/bar#anchor2</router-link></li>
+ <li><router-link to="/bar#1number">/bar#1number</router-link></li>
+ </ul>
+ <router-view class="view" v-slot="{ Component, props }">
+ <transition
+ name="fade"
+ mode="out-in"
+ @before-enter="flushWaiter"
+ @before-leave="setupWaiter"
+ >
+ <component :is="Component" v-bind="props"></component>
+ </transition>
+ </router-view>
+ </div>
+ `,
})
app.use(router)
function add() {
promise = new Promise(r => {
- resolve = resolve
+ resolve = r
})
}
'encodes values': function(browser) {
browser
.url(baseURL)
- // TODO: move this test to a different spec
.assert.urlEquals(baseURL + '/')
- .waitForElementVisible('#app', 1000)
+ .waitForElementPresent('#app > *', 1000)
.click('li:nth-child(3) a')
.assert.urlEquals(baseURL + '/documents/%E2%82%ACuro')
// check initial visit
.url(baseURL + '/documents/%E2%82%ACuro')
- .waitForElementVisible('#app', 1000)
+ .waitForElementPresent('#app > *', 1000)
.assert.containsText('#fullPath', '/documents/%E2%82%ACuro')
.assert.containsText('#path', '/documents/%E2%82%ACuro')
.assert.containsText('#params', JSON.stringify({ id: '€uro' }, null, 2))
+ // TODO: invalid in safari, tests on those where this is valid
+ // .url(baseURL + '/unicode/€uro')
+ // .waitForElementPresent('#app > *', 1000)
+ // navigation to unencoded value
+ // depending on the browser the value will be encoded or not
+ // .assert.containsText('#params', JSON.stringify({ id: '€uro' }, null, 2))
+
.end()
},
}
'navigating to links': function(browser) {
browser
.url(baseURL)
- .waitForElementVisible('#app', 1000)
+ .waitForElementPresent('#app > *', 1000)
.assert.attributeContains('li:nth-child(1) a', 'href', '/hash/#/')
.assert.attributeContains('li:nth-child(2) a', 'href', '/hash/#/foo')
.assert.attributeContains('li:nth-child(3) a', 'href', '/hash/#/bar')
/** @type {import('nightwatch').NightwatchTest} */
'encoding on initial navigation': function(browser) {
browser
- .url(baseURL + '/unicode/é')
- // navigation to unencoded value
- // depending on the browser the value will be encoded or not
- .assert.containsText('#param', 'é')
.url(baseURL + '/unicode/%C3%A9')
// navigation to unencoded value
.assert.urlEquals(baseURL + '/unicode/%C3%A9')
.assert.containsText('#path', '/unicode/%C3%A9')
.assert.containsText('#param', 'é')
+ // TODO: invalid in safari, tests on those where this is valid
+ // .url(baseURL + '/unicode/é')
+ // navigation to unencoded value
+ // depending on the browser the value will be encoded or not
+ // .assert.containsText('#param', 'é')
+
.end()
},
}
'changes the url': function(browser) {
browser
.url(baseURL)
- .waitForElementVisible('#app', 1000)
+ .waitForElementPresent('#app > *', 1000)
.assert.containsText('h1', 'Home')
.assert.not.visible('dialog')
'can close and reopen the modal through history'(browser) {
browser
.url(baseURL)
- .waitForElementVisible('#app', 1000)
+ .waitForElementPresent('#app > *', 1000)
.assert.containsText('h1', 'Home')
.click('li:nth-child(2) button')
'can keep the modal when reloading'(browser) {
browser
.url(baseURL)
- .waitForElementVisible('#app', 1000)
+ .waitForElementPresent('#app > *', 1000)
.assert.containsText('h1', 'Home')
.click('li:nth-child(2) button')
'can pass through the modal and then back'(browser) {
browser
.url(baseURL)
- .waitForElementVisible('#app', 1000)
+ .waitForElementPresent('#app > *', 1000)
.assert.containsText('h1', 'Home')
.assert.not.visible('dialog')
'can navigate away from the modal then come back'(browser) {
browser
.url(baseURL)
- .waitForElementVisible('#app', 1000)
+ .waitForElementPresent('#app > *', 1000)
.assert.containsText('h1', 'Home')
.click('li:nth-child(2) button')
browser
.url(baseURL)
.assert.urlEquals(baseURL + '/')
- .waitForElementVisible('#app', 1000)
+ .waitForElementPresent('#app > *', 1000)
.click('li:nth-child(2) a')
.assert.urlEquals(baseURL + '/cant-leave')
.assert.containsText('#tries', '0 times')
browser
.url('http://localhost:8080/scroll-behavior/')
- .waitForElementVisible('#app', 1000)
+ .waitForElementPresent('#app > *', 1000)
.assert.count('li a', 6)
.assert.containsText('.view', 'home')
browser
.url('http://localhost:8080/transitions/')
- .waitForElementVisible('#app', 1000)
+ .waitForElementPresent('#app > *', 1000)
.click('li:nth-child(2) a')
.assert.cssClassPresent('.view.home', 'fade-leave-active')
<a href="/"><< Back to Homepage</a>
<hr />
- <div id="app">
- <h1>Transitions</h1>
- <ul>
- <li><router-link to="/">/</router-link></li>
- <li><router-link to="/parent">/parent</router-link></li>
- <li><router-link to="/parent/foo">/parent/foo</router-link></li>
- <li><router-link to="/parent/bar">/parent/bar</router-link></li>
- </ul>
- <router-view class="view" v-slot="{ Component, props }">
- <transition name="fade" mode="out-in">
- <component :is="Component" v-bind="props"></component>
- </transition>
- </router-view>
- </div>
+ <main id="app"></main>
</body>
</html>
route: useRoute(),
}
},
+
+ template: `
+ <div id="app">
+ <h1>Transitions</h1>
+ <ul>
+ <li><router-link to="/">/</router-link></li>
+ <li><router-link to="/parent">/parent</router-link></li>
+ <li><router-link to="/parent/foo">/parent/foo</router-link></li>
+ <li><router-link to="/parent/bar">/parent/bar</router-link></li>
+ </ul>
+ <router-view class="view" v-slot="{ Component, props }">
+ <transition name="fade" mode="out-in">
+ <component :is="Component" v-bind="props"></component>
+ </transition>
+ </router-view>
+ </div>
+ `,
})
app.use(router)