Fix chrome.runtime.sendMessage

add a case of not provide extension-id: (message, responseCallback)
This commit is contained in:
Jhen 2016-06-22 19:47:07 +08:00
parent 86e98950cc
commit 233355ed09

View file

@ -119,7 +119,13 @@ exports.injectTo = function (extensionId, isBackgroundPage, context) {
if (args.length === 1) {
message = args[0]
} else if (args.length === 2) {
[targetExtensionId, message] = args
// A case of not provide extension-id: (message, responseCallback)
if (typeof args[1] === 'function') {
console.error('responseCallback is not supported')
message = args[0]
} else {
[targetExtensionId, message] = args
}
} else {
console.error('options and responseCallback are not supported')
}