* @param {string} src * @param {string=} fallbackSrc * @param {string=} customElement * @param {string=} customTemplate
(src, fallbackSrc, customElement, customTemplate)
| 312 | * @param {string=} customTemplate |
| 313 | */ |
| 314 | installScript_(src, fallbackSrc, customElement, customTemplate) { |
| 315 | const doc = this.win.document; |
| 316 | const el = doc.createElement('script'); |
| 317 | el.setAttribute('src', src); |
| 318 | if (customElement) { |
| 319 | el.setAttribute('custom-element', customElement); |
| 320 | } |
| 321 | if (customTemplate) { |
| 322 | el.setAttribute('custom-template', customTemplate); |
| 323 | } |
| 324 | el.onload = () => { |
| 325 | log('- script added: ', src, el); |
| 326 | }; |
| 327 | el.onerror = () => { |
| 328 | log('- script failed to load: ', src, el); |
| 329 | doc.head.removeChild(el); |
| 330 | if (fallbackSrc) { |
| 331 | this.installScript_( |
| 332 | fallbackSrc, |
| 333 | undefined, |
| 334 | customElement, |
| 335 | customTemplate |
| 336 | ); |
| 337 | } |
| 338 | }; |
| 339 | doc.head.appendChild(el); |
| 340 | } |
| 341 | |
| 342 | /** |
| 343 | * @param {string} url |
no test coverage detected