worker-dom icon indicating copy to clipboard operation
worker-dom copied to clipboard

APIs needed by Vue

Open dreamofabear opened this issue 6 years ago • 3 comments

Not a comprehensive list. As of writing, just the ones I encountered when trying to get "hello world" example to work on Vue 2.6.5 (dev).

window.navigator.userAgent

Uncaught TypeError: Cannot read property 'userAgent' of undefined
var UA = inBrowser && window.navigator.userAgent.toLowerCase();

document.createEvent()

Uncaught TypeError: document.createEvent is not a function
// Determine what event timestamp the browser is using. Annoyingly, the
// timestamp can either be hi-res (relative to page load) or low-res
// (relative to UNIX epoch), so in order to compare time we have to use the
// same timestamp type when saving the flush timestamp.
if (inBrowser && getNow() > document.createEvent('Event').timeStamp) {

Set innerHTML

Uncaught TypeError: Cannot set property innerHTML of #<Element> which has only a getter
function getShouldDecode(href) {
    div = div || document.createElement('div');
    div.innerHTML = href ? "<a href=\"\n\"/>" : "<div a=\"\n\"/>";
    return div.innerHTML.indexOf('&#10;') > 0
}
var he = {
  decode: function decode (html) {
    decoder = decoder || document.createElement('div');
    decoder.innerHTML = html;
    return decoder.textContent
  }
};

new Vue()

Uncaught ReferenceError: Vue is not defined

Not really an API. Vue's global wrapper sets a property on workerDOM's custom this scope. Similar issue to our need to set var document = this.document; etc.

One workaround is to insert const Vue = this.Vue; between framework code and author code.

dreamofabear avatar Feb 11 '19 16:02 dreamofabear

I support your effort to make Vue run in worker-dom. What is more, Vue 3.0 will be platform-agnostic, which should make it even easier.

niutech avatar Mar 25 '19 14:03 niutech

I have made a TodoMVC demo using unmodified Vue.js 2.6 in the latest worker-dom and it generally works fine - see #406.

niutech avatar Apr 03 '19 00:04 niutech

I made a demo boilerplate app using the latest Vue.js 2.6.12 and it works fine: vue-in-web-worker.

niutech avatar Nov 10 '20 17:11 niutech