-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enable onload callbacks (#414)
* refactor(examples): run ssr example from server * chore: switch to babel for build buble complains too much * feat: enable loaded callbacks feat: add skip option * examples: add async-callback browser example * examples: fix server * examples(ssr): add reactive script with callback * fix: also skip on ssr * chore: remove unused var * feat: only add mutationobserver if DOM is still loading feat: disconnect mutation observer once DOM has loaded * examples: pass vmid to loadCallback instead of el * feat: also support load callbacks for link/style tags * test: add unit tests for load * test: add load e2e test * chore: fix lint * chore: remove unused files * test: fix e2e load callback test * test: fix attempt * examples: ie9 compatiblity destructuring doesnt work in ie9 * fix: add onload attribute on ssr dont rely on mutationobserver * chore: lint ci conf * refactor: remove loadCallbackAttribute config option test: fix coverage for load * test: improve coverage * fix: only use console when it exists (for ie9) * chore: fix coverage
- Loading branch information
Showing
49 changed files
with
957 additions
and
626 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,5 +134,3 @@ workflows: | |
requires: [test-e2e-ssr] | ||
filters: | ||
branches: { ignore: /^pull\/.*/ } | ||
|
||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
window.users.push({ | ||
'id': 1, | ||
'name': 'Leanne Graham', | ||
'username': 'Bret', | ||
'email': 'Sincere@april.biz', | ||
'address': { | ||
'street': 'Kulas Light', | ||
'suite': 'Apt. 556', | ||
'city': 'Gwenborough', | ||
'zipcode': '92998-3874', | ||
'geo': { | ||
'lat': '-37.3159', | ||
'lng': '81.1496' | ||
} | ||
}, | ||
'phone': '1-770-736-8031 x56442', | ||
'website': 'hildegard.org', | ||
'company': { | ||
'name': 'Romaguera-Crona', | ||
'catchPhrase': 'Multi-layered client-server neural-net', | ||
'bs': 'harness real-time e-markets' | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
window.users.push({ | ||
'id': 2, | ||
'name': 'Ervin Howell', | ||
'username': 'Antonette', | ||
'email': 'Shanna@melissa.tv', | ||
'address': { | ||
'street': 'Victor Plains', | ||
'suite': 'Suite 879', | ||
'city': 'Wisokyburgh', | ||
'zipcode': '90566-7771', | ||
'geo': { | ||
'lat': '-43.9509', | ||
'lng': '-34.4618' | ||
} | ||
}, | ||
'phone': '010-692-6593 x09125', | ||
'website': 'anastasia.net', | ||
'company': { | ||
'name': 'Deckow-Crist', | ||
'catchPhrase': 'Proactive didactic contingency', | ||
'bs': 'synergize scalable supply-chains' | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
window.users.push({ | ||
'id': 3, | ||
'name': 'Clementine Bauch', | ||
'username': 'Samantha', | ||
'email': 'Nathan@yesenia.net', | ||
'address': { | ||
'street': 'Douglas Extension', | ||
'suite': 'Suite 847', | ||
'city': 'McKenziehaven', | ||
'zipcode': '59590-4157', | ||
'geo': { | ||
'lat': '-68.6102', | ||
'lng': '-47.0653' | ||
} | ||
}, | ||
'phone': '1-463-123-4447', | ||
'website': 'ramiro.info', | ||
'company': { | ||
'name': 'Romaguera-Jacobson', | ||
'catchPhrase': 'Face to face bifurcated interface', | ||
'bs': 'e-enable strategic applications' | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
window.users.push({ | ||
'id': 4, | ||
'name': 'Patricia Lebsack', | ||
'username': 'Karianne', | ||
'email': 'Julianne.OConner@kory.org', | ||
'address': { | ||
'street': 'Hoeger Mall', | ||
'suite': 'Apt. 692', | ||
'city': 'South Elvis', | ||
'zipcode': '53919-4257', | ||
'geo': { | ||
'lat': '29.4572', | ||
'lng': '-164.2990' | ||
} | ||
}, | ||
'phone': '493-170-9623 x156', | ||
'website': 'kale.biz', | ||
'company': { | ||
'name': 'Robel-Corkery', | ||
'catchPhrase': 'Multi-tiered zero tolerance productivity', | ||
'bs': 'transition cutting-edge web services' | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import Vue from 'vue' | ||
import VueMeta from 'vue-meta' | ||
|
||
Vue.use(VueMeta) | ||
|
||
window.users = [] | ||
|
||
new Vue({ | ||
metaInfo () { | ||
return { | ||
title: 'Async Callback', | ||
titleTemplate: '%s | Vue Meta Examples', | ||
script: [ | ||
{ | ||
skip: this.count < 2, | ||
vmid: 'potatoes', | ||
src: '/user-3.js', | ||
async: true, | ||
callback: this.updateCounter | ||
}, | ||
{ | ||
skip: this.count < 1, | ||
vmid: 'vegetables', | ||
src: '/user-2.js', | ||
async: true, | ||
callback: this.updateCounter | ||
}, | ||
{ | ||
vmid: 'meat', | ||
src: '/user-1.js', | ||
async: true, | ||
callback: el => this.loadCallback(el.getAttribute('data-vmid')) | ||
}, | ||
...this.scripts | ||
] | ||
} | ||
}, | ||
data () { | ||
return { | ||
count: 0, | ||
scripts: [], | ||
users: window.users | ||
} | ||
}, | ||
watch: { | ||
count (val) { | ||
if (val === 3) { | ||
this.addScript() | ||
} | ||
} | ||
}, | ||
methods: { | ||
updateCounter () { | ||
this.count++ | ||
}, | ||
addScript () { | ||
this.scripts.push({ | ||
src: '/user-4.js', | ||
callback: () => { | ||
this.updateCounter() | ||
} | ||
}) | ||
}, | ||
loadCallback (vmid) { | ||
if (vmid === 'meat') { | ||
this.updateCounter() | ||
} | ||
} | ||
}, | ||
template: ` | ||
<div id="app"> | ||
<h1>Async Callback</h1> | ||
<p>{{ count }} scripts loaded</p> | ||
<div> | ||
<h2>Users</h2> | ||
<ul> | ||
<li | ||
v-for="user in users" | ||
:key="user.id" | ||
> | ||
<strong>{{ user.id }}</strong>: {{ user.name }} | ||
</li> | ||
</ul> | ||
</div> | ||
</div> | ||
` | ||
}).$mount('#app') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Async Callback Title</title> | ||
<link rel="stylesheet" href="/global.css"> | ||
</head> | ||
<body> | ||
<a href="/">← Examples index</a> | ||
<div id="app"></div> | ||
|
||
<script src="/__build__/async-callback.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.