google / google/elemental2

Type Checking for MutationRecord gives ClassCastException in Chrome

Open
#140 10 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
170
Forks
41
PR merge metrics
No merged PRs in 30d

Description

The follow code gives ClassCastException in Chrome(Version 83.0.4103.61 (Official Build) (64-bit)) and new Edge(Version 83.0.478.37 (Official build) (64-bit)) but not Edge Legacy

``` Java
private void setupMutation(Node target) {
Consumer recordConsumer = mutationRecord -> DomGlobal.console.log("oldValue", mutationRecord.oldValue);

MutationObserverInit mutationObserverInit = MutationObserverInit.create();
mutationObserverInit.setAttributes(true);
mutationObserverInit.setChildList(true);
mutationObserverInit.setSubtree(true);

MutationObserver mutationObserver = new MutationObserver(new MutationObserver.MutationObserverCallbackFn() {
public Object onInvoke(JsArray recordJsArray, MutationObserver observer) {
recordJsArray.forEach((recordConsumer1, ignore, params) -> {
recordConsumer.accept(recordConsumer1);
return null;
});

return null;
}
});

mutationObserver.observe(target, mutationObserverInit);
}
```

Below is the type check that fails for MutationObserver. In the console there is a test againt $wnd and window for the mutationRecord instance

![image](https://user-images.githubusercontent.com/36953892/82738691-efcb5b80-9d39-11ea-9a34-f7ecca413be9.png)

And the generated code where castToNative is used.

![image](https://user-images.githubusercontent.com/36953892/82738717-286b3500-9d3a-11ea-8da3-c9df62342ad0.png)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.