Bug Tracker

Opened 16 years ago

Closed 14 years ago

#1675 closed bug (fixed)

expando related problem on removeData()

Reported by: dimi Owned by: flesler
Priority: major Milestone: 1.4.3
Component: data Version: 1.4.2
Keywords: Cc:
Blocked by: Blocking:

Description

During a simple remove() call on a <div> that contains a Java applet via a <embed> tag, I get this error: java class com.x.y.z has no public field or method named "jQuery12332451234"

on line 555 of jQuery 1.2.1 where we do a delete elem[ expando ];

This error is in Firefox 2.0.0.5 on Linux. Quite severe problem.

Change History (16)

comment:1 Changed 16 years ago by dimi

To temporarily fix the problem, I've added this:

if (elem.nodeName.toLowerCase() == 'embed') return;

at the beginning of the removeData() function.

comment:2 Changed 16 years ago by brandon

Resolution: fixed
Status: newclosed

I believe this has already been fixed in SVN. I was unable to reproduce this. Please feel free to reopen if you still experience this issue with the latest SVN and attach a test case.

comment:3 Changed 16 years ago by anthony

Resolution: fixed
Status: closedreopened

When a $("#divName").html("") is called on a div tag (id="divName") that contains a java applet, the error above still exists:

Java class ptviewer has no public field or method named "jQuery1195256692140" http://localhost:8080/t/resources/rpm3.0/js/lib/jQuery/jquery-1.2.1.js Line 555

This occurs in Firefox but not in IE 6 & 7.

Test Case:

I have a page that displays virtual tours with an applet called PTViewer(http://www.fsoft.it/panorama/ptviewer.htm) and is set up in a way similar to a slideshow in that the problematic div holds the embedded virtual tour and beside it is a jCarousel which changes that div to the tour that you click on. When it first loads up, the applet works fine but when you click on any other button/image that replaces the code (in jCarousel or otherwise) in the problematic div the error occurs.

Temporary Solution:

The code on line 555 of jquery-1.2.1.js is as such:

delete elem[ expando ];

This line is surrounded by a try/catch block so you would think it would go to catch when the error occurs but instead it doesn't and the embedded code is still there on the page. If I only let IE run that line:

if(jquery.browser.msie){
  delete elem[ expando ];
}else{
  if ( elem.removeAttribute )
   elem.removeAttribute( expando );
}

Then this works. Please note that the code in the else portion is also in the catch portion of the try/catch statement that the suspect line resides in.

comment:4 Changed 16 years ago by JesperSJense

I have same problem in firefox version 2.0.0.12. 'xx.xxx.xxxx.class has no public field or method named "JQuery....' Error introduced AFTER 1.2.1!

My html produce a valid html document with a applet tag. And everything works fine with jquery 1.2.1. Error is when leaving page (cleanup cache?) My html:

... <div class="applet">

<script type="text/javascript">

/*<![CDATA[*/writeApplet('appletId','xx.xxx.xxxx.class','appletName','600','350','xxx.jar','/','MAYSCRIPT',{'archive':'xxx.jar','Cabbase':'xxx.cab','agent':+navigator.userAgent+});/*]]>*/

</script>

<script type="text/javascript">

/*<![CDATA[*/document.write('<\/applet>')/*]]>*/

</script>

</div>

In jquery 1.2.3 (developer version) error is in line 674 (it seems to be when cleaning cache for elem = script!).

Compute a unique ID for the element

673 if ( !id )

674 id = elem[ expando ] = ++uuid;

675

regards,

JesperSJensen

comment:5 Changed 15 years ago by DanSwitzer2

I'm also having problems with applets in Firefox v2.x. It appears that the root problem is that you can't set expando on a Java applet tag (regardless if the tag's been written with the embed, object or applet tag.)

I could live without being able to alter an applet tag, but this causes problems with pages that just contain applets, since jQuery attempts to unbind all events on the element during the window.unload event.

comment:6 Changed 15 years ago by flesler

Milestone: 1.2.21.2.4
Resolution: fixed
Status: reopenedclosed

This is how that part looks now:

try {
  delete elem[ expando ];
} catch(e){
  // IE has trouble directly removing the expando
  // but it's ok with using removeAttribute
  if ( elem.removeAttribute )
     elem.removeAttribute( expando );
  }

So there's no chance of getting an error. I declare this fixed.

comment:7 Changed 15 years ago by Tom

For the other side of things (data() instead of removeData())...

Unwrapped elem[ expando ] in jquery-1.2.6.js for data():
554 Compute a unique ID for the element
665 if ( !id )
666 id = elem[ expando ] = ++uuid;

Java class XXX has no public field or method named "jQuery1213636634264"

There's a ticket open for it #2349.

comment:8 Changed 15 years ago by flesler

Milestone: 1.2.41.3
Resolution: fixed
Status: closedreopened

comment:9 Changed 15 years ago by flesler

Owner: set to flesler
Status: reopenednew

comment:10 Changed 15 years ago by flesler

Status: newassigned

comment:11 Changed 15 years ago by hans

I see this problem in IE8 in IE7 compatibility mode now: Apparently, it is not possible to remove a Java Applet using jQuery, but I also have not found a workaround yet.

A demonstration of the problem is at http://vaxbusters.org/applet-prob.html

comment:12 in reply to:  11 Changed 15 years ago by hans

Replying to hans:

I see this problem in IE8 in IE7 compatibility mode now: Apparently, it is not possible to remove a Java Applet using jQuery, but I also have not found a workaround yet.

A workaround is to remove the applet element using direct DOM manipulation:

    var applet = $("#applet")[0];
    if (applet) {
        applet.parentNode.removeChild(applet);
    }

comment:13 Changed 15 years ago by nphase

A previously mentioned (in (#2349) http://82.170.249.144/mediaBeez/lib/jquery/jquery-1.2.6.source_VIS.js

Seems to have worked for me, but only in tandem with replacing this:

$('#loader').load(this.href);

with:

$.get(this.href, function(data)
{
	var applet = $('#loader applet')[0];
	var loader = $('#loader')[0];
	if(applet)
	{
		applet.parentNode.removeChild(applet);
	}
			
	loader.innerHTML = data;
});

Hopepfully this finds someone well.

comment:19 Changed 14 years ago by john

Component: coredata
Milestone: 1.31.4
Resolution: fixed
Status: assignedclosed
Version: 1.2.11.4a1

comment:20 Changed 14 years ago by phoneder

Resolution: fixed
Status: closedreopened

I think this problem persists again, I currently have the same problem and as far as I can see the reason in jquery 1.4.2 is line 4514:

id = elem[ jQuery.expando ];

a simple fix would be to use jQuery.noData which was the previous fix for this issue.

I will prepare a patch if you agree to doing this, but I have not yet full insight in the internals of jQuery. So I simply don't know if this solves the problem or leaves events or other stuff uncleaned:

for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
  if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
    continue;
  }			
  id = elem[ jQuery.expando ];
  ...
}

The original code to reproduce was to have something like:

<div id='a'>
  <applet ...></applet
</div>

and then just empty it using either empty() or html(), e.g.:

$('#a').empty();

comment:21 Changed 14 years ago by john

Milestone: 1.41.4.3
Resolution: fixed
Status: reopenedclosed
Version: 1.4a11.4.2
Note: See TracTickets for help on using tickets.