From 05a55ad45feff731284703d0292a660ec29c7aa6 2018-08-17 18:18:48 From: Grant Nestor Date: 2018-08-17 18:18:48 Subject: [PATCH] Take jquery's getScript approach --- diff --git a/IPython/core/display.py b/IPython/core/display.py index 521cae8..ca5c3aa 100644 --- a/IPython/core/display.py +++ b/IPython/core/display.py @@ -859,16 +859,17 @@ _css_t = """var link = document.createElement("link"); document.head.appendChild(link); """ -_lib_t1 = """var script = document.createElement("script"); - script.type = "text/javascript"; +_lib_t1 = """new Promise(function(resolve, reject) { + var script = document.createElement("script"); + script.onload = resolve; + script.onerror = reject; script.src = "%s"; - script.onload = script.onreadystatechange = function() { - if (!this.readyState || this.readyState == 'complete') { + document.head.appendChild(script); +}).then(() => { """ -_lib_t2 = """} - }; - document.head.appendChild(script);""" +_lib_t2 = """ +});""" class GeoJSON(JSON): """GeoJSON expects JSON-able dict