In JSInterop calls, use expected value for 'this'. Fixes dotnet/extensions#1477 (dotnet/extensions#1990)
\n\nCommit migrated from a664ecb5b3
This commit is contained in:
parent
97a039f154
commit
86b55046c9
|
|
@ -141,14 +141,6 @@ module DotNet {
|
|||
* Receives incoming calls from .NET and dispatches them to JavaScript.
|
||||
*/
|
||||
export const jsCallDispatcher = {
|
||||
/**
|
||||
* Finds the JavaScript function matching the specified identifier.
|
||||
*
|
||||
* @param identifier Identifies the globally-reachable function to be returned.
|
||||
* @returns A Function instance.
|
||||
*/
|
||||
findJSFunction,
|
||||
|
||||
/**
|
||||
* Invokes the specified synchronous JavaScript function.
|
||||
*
|
||||
|
|
@ -227,8 +219,10 @@ module DotNet {
|
|||
|
||||
let result: any = window;
|
||||
let resultIdentifier = 'window';
|
||||
let lastSegmentValue: any;
|
||||
identifier.split('.').forEach(segment => {
|
||||
if (segment in result) {
|
||||
lastSegmentValue = result;
|
||||
result = result[segment];
|
||||
resultIdentifier += '.' + segment;
|
||||
} else {
|
||||
|
|
@ -237,6 +231,8 @@ module DotNet {
|
|||
});
|
||||
|
||||
if (result instanceof Function) {
|
||||
result = result.bind(lastSegmentValue);
|
||||
cachedJSFunctions[identifier] = result;
|
||||
return result;
|
||||
} else {
|
||||
throw new Error(`The value '${resultIdentifier}' is not a function.`);
|
||||
|
|
|
|||
Loading…
Reference in New Issue