(url: string)
| 137 | } |
| 138 | |
| 139 | applyUrl(url: string) { |
| 140 | if (this.lastUrl === url) { |
| 141 | return; |
| 142 | } |
| 143 | this.lastContent = undefined; |
| 144 | this.lastUrl = url; |
| 145 | const element = document.createElement('link'); |
| 146 | element.onload = onload; |
| 147 | element.onerror = onload; |
| 148 | |
| 149 | const i = createDefer(); |
| 150 | function onload(e: any) { |
| 151 | element.onload = null; |
| 152 | element.onerror = null; |
| 153 | if (e.type === 'load') { |
| 154 | i.resolve(); |
| 155 | } else { |
| 156 | i.reject(); |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | element.href = url; |
| 161 | element.rel = 'stylesheet'; |
| 162 | if (this.id) { |
| 163 | element.setAttribute('data-id', this.id); |
| 164 | } |
| 165 | document.head.insertBefore(element, this.placeholder.parentNode === document.head ? this.placeholder.nextSibling : null); |
| 166 | document.head.removeChild(this.placeholder); |
| 167 | this.placeholder = element; |
| 168 | return i.promise(); |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | function parseAssetList(scripts: any, styles: any, assets: AssetList, level?: AssetLevel) { |
no test coverage detected