postMessage JSON 在 Google Chrome 中的编码/解码是否与在 Firefox 中一样?
我知道它是 HTML5 规范的一部分,但有时 WebKit 不符合最新的规范草案。
I know its part of the HTML5 spec, but sometimes WebKit doesn't conform to the latest draft of the spec.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
唉,WebKit 的辅助 postMessage 实现当前不会序列化对象,因为它是写入规范的早期版本,并且尚未更新以匹配“最终”版本。
它实际上也不是 JSON —— 它是 html5 中的内部结构化克隆算法,它更高效(它不需要与字符串相互转换)并且实际上比 JSON 更丰富,但是目前没有人实现这一点:-(
Alas WebKit's worker postMessage implementation doesn't currently serialise objects as it was written to an earlier version of the spec, and hasn't yet been updated to match the "final" version.
It's not actually JSON either -- it's the internal structured cloning algorithm in html5, which is more efficient (it doesn't need to convert to and from string) and actually somewhat richer than JSON, however no one currently implements that :-(
更新:从 Firefox 6.0 消息参数使用 结构化克隆算法。现在它似乎也可以在 Chrome 中运行。
Update: From Firefox 6.0 the message parameter is serialized using the structured clone algorithm. It seems to work in Chrome now as well.