src/clientVueLoader.js
// Loads the component from its url.
Loads the component from its url.
Loads the component from its url .
async load() {
            this.content = await VueComponent.httpRequest(this.url);
            const doc = document.implementation.createHTMLDocument('');
            doc.head.innerHTML += `<base href="${this.url}">`;
            doc.body.innerHTML = this.content;
            for (let i = 0; i < doc.body.children.length; i++) {
                let element = doc.body.children[i];
                switch (element.nodeName) {
                    case 'TEMPLATE':
                        if (this.template) {
                            throw new Error(`Duplicated <template> tag at url(${this.url})\n${this.content}`);
                        }
                        this.template = new TagContext(this, element);
                        this.addTag(this.template);
                        break;
                    case 'SCRIPT':
                        if (this.script) {
                            throw new Error(`Duplicated <script> tag at url(${this.url})\n${this.content}`);
                        }
                        this.script = new TagContext(this, element);
                        this.addTag(this.script);
                        break;
                    default:
                        this.addTag(new TagContext(this, element));
                        break;
                }
            }
            if (this.template || this.script) {
                return this;
            }
            throw new Error(
                `There isn't a template or a script tag in the loaded vue document at url(${this.url})\n${responseText}`);
        }
async load ( ) { this . content = await VueComponent . httpRequest ( this . url ) ; const doc = document . implementation . createHTMLDocument ( '' ) ; doc . head . innerHTML += ` ${ this . url } ` ; doc . body . innerHTML = this . content ; for ( let i = 0 ; i < doc . body . children . length ; i ++ ) { let element = doc . body . children [ i ] ; switch ( element . nodeName ) { case 'TEMPLATE' : if ( this . template ) { throw new Error ( ` ${ this . url } \n ${ this . content } ` ) ; } this . template = new TagContext ( this , element ) ; this . addTag ( this . template ) ; break ; case 'SCRIPT' : if ( this . script ) { throw new Error ( ` ${ this . url } \n ${ this . content } ` ) ; } this . script = new TagContext ( this , element ) ; this . addTag ( this . script ) ; break ; default : this . addTag ( new TagContext ( this , element ) ) ; break ; } } if ( this . template || this . script ) { return this ; } throw new Error ( ` ${ this . url } \n ${ responseText } ` ) ; }
Loads the component from its url.
Loads the component from its url .
// IE requires the <base> to come with <style> // NOTE: skip the base node.