提交 bc075762 编写于 作者: M Matt Bierner

Use map for handlers

上级 ecb1a65b
......@@ -16,7 +16,7 @@
<script>
(function () {
const id = document.location.search.match(/\bid=([\w\-]+)/)[1];
const handlers = {};
const handlers = new Map();
const postMessageToVsCode = (channel, data) => {
window.parent.postMessage({ target: id, channel, data }, '*');
......@@ -30,7 +30,7 @@
}
const channel = e.data.channel;
const handler = handlers[channel];
const handler = handlers.get(channel);
if (handler) {
handler(e, e.data.args);
} else {
......@@ -44,7 +44,7 @@
postMessageToVsCode(channel, data);
},
onMessage: (channel, handler) => {
handlers[channel] = handler;
handlers.set(channel, handler);
}
});
}());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册