The object does not support this property or method.

After upgrading my version of GWT to 2.5.0, I have a problem when I hover over a chart (SVG).

The problem appears only in IE (Chrome and Firefox are not affected).

Message

2 catch exceptions: (TypeError) description: Object does not support the property or method 'contains' number: -2146827850: The object does not support the property or method 'contains';

The problem seems to be caused by a new method in the DOMImplTrident class called isOrHasChildImpl .

I am wondering if anyone else encounters this problem or knows about working around except to not use IE;)

thanks

+4
source share
1 answer

This is just a guess, but I suspect your problem comes from line 53 of the DOMImplTrident.isOrHasChildImpl method.

 return (parent === child) || parent.contains(child); 

I also assume that you encountered your errors in IE10? The reason I think you're working against IE10 is because GWT does not officially support IE10 with a separate DOM implementation. In the end, he will use the implementation of DOMImplIE9 in IE10, which in turn uses the above method from DOMImplTrident to implement 'isOrHasChild'. I am wondering if line 47

 if (parent.nodeType == 9) { 

it doesn’t actually return 9 for the node document and is thereby discarded into the else statement for the node document and explodes when it tries to access the contains method. Perhaps IE10 does not implement these node methods in the same way as previous versions of IE? Not sure.

I do not have IE10 to test this theory, but this may be a good start. You can create your own JSNI method that will make similar node calls to test the theory and see if "document.nodeType" returns 9, or if "node.contains" explodes on different types of nodes.

If that turns out to be a problem. You can try several things to fix / avoid the problem.

  • Try connecting GWT.setUncaughtExceptionHandler () at your entry point and just ignore the error.

  • Insert a try / catch block of code in one of your methods that raises the problem code and ignores the exception.

  • Try adding the following meta tag to your html file and see if rendering will work in IE10, since IE9 solves the problem.

     <meta http-equiv="X-UA-Compatible" content="IE=9" /> 
  • Create your own DOMImpl, which extends DOMImplIE9 and overrides the isOrHasChild method using its own method in which you control what is happening. for instance

     package com.google.gwt.dom.client; public class DOMImplIE9Custom extends DOMImplIE9 { @Override public boolean isOrHasChild(Node parent, Node child) { // Do your own thing } } 

Then you use deferred binding to switch DOMImplIE9 with your custom implementation like this:

 <replace-with class="com.google.gwt.dom.client.DOMImplIE9Custom"> <when-type-is class="com.google.gwt.dom.client.DOMImpl"/> <when-property-is name="user.agent" value="ie9"/> </replace-with> 

Even if I am leaving the base and you are not using IE10, you can still try the above ideas to get around this problem. Either this, or make a final correction and stop using IE in general and avoid many hours of stress :) I hope that helps you at least on the right track.

+3
source

Source: https://habr.com/ru/post/1494243/


All Articles