UNPKG

dingtalk-docs-cool-app

Version:

钉钉文档酷应用插件扩展 开发者初始化包

1 lines 689 B
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.loadScript=loadScript;var _error=require("./types/error");function loadScript(t,e={}){const r=document.head||document.getElementsByTagName("head")[0],n=document.createElement("script");n.type=e.type||"text/javascript",n.async="async"in e&&!!e.async,n.src=t,setAttributes(n,e.attrs);const o=new Promise(((t,e)=>{n.onload=function(){this.onerror=null,this.onload=null,t()},n.onerror=function(){this.onerror=null,this.onload=null,e(new _error.Exception("internal_error",`Failed to load ${this.src}`))}}));return r.appendChild(n),o}function setAttributes(t,e){e&&Object.keys(e).forEach((r=>{t.setAttribute(r,e[r])}))}