fetch-polyfill icon indicating copy to clipboard operation
fetch-polyfill copied to clipboard

how jsonp works?

Open meooxx opened this issue 5 years ago • 0 comments

https://github.com/RubyLouvre/fetch-polyfill/blob/0ec48d47e02b82e8e4fb79618db929ceae507cf6/src/transports/jsonp.js#L2-L51 1 所有的方法没有挂在原型上面, 全是挂在xhr上面的, 不应挂在原型上吗, 或者 this.xhr = xhr 最后导致 new JSONP出来是一个空到实例 2 open 方法将节点 挂在 head中, 不是应该是getElementsByTagName,原文是getElementsTagName 实在没在文档上找到这个方法。 3 remove 方法, 命名节点插入到dom 中, 为什么

var f = document.createDocumentFragment()
var useOnload = 'textContent' in document

function removeNode(node) {
    f.appendChild(node)
    f.removeChild(node)
    node.onload = onerror = onreadystatechange = function () {
    }
    return node
}

这样 操作?为什么可以从真实dom中移除呢?

我看代码实现de时候,单独把JSONP 单独ling出来放在本地跑 发现上述问题, 请帮忙解答多谢🙏

meooxx avatar Mar 18 '19 13:03 meooxx