Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object tag with svg being ignored at contents() #4045

emibloque opened this issue Apr 18, 2018 · 0 comments

Object tag with svg being ignored at contents() #4045

emibloque opened this issue Apr 18, 2018 · 0 comments


Copy link

First of all, thank you very much for this project and for your work!


A regression could have been introduced in this commit 3e3b09d and, as it is returning documentContent only for <iframe>, it is no longer possible to access the document content of an <object> with an svg provided in the data attribute.

For example this would stop working since version 3.2.0:

<object id="svg-object" data="1x1.svg"></object>
var svgObject = $("#svg-object")

svgObject.on("load", function(){

Test link

The test to reproduce this bug would need a svg in the same domain, as it isn't possible to upload it to any of the platforms, I cannot provide a test link. However, I've prepared a PR with the fix and the test case provided in it is the following:

QUnit.test( "contents() for <object />", function( assert ) {
	assert.expect( 2 );

	var svgObject = jQuery( "<object id='svg-object' data='" + baseURL + "1x1.svg'></object>" );
	var done = assert.async();

	svgObject.on( "load", function() {
		var contents = jQuery( "#svg-object" ).contents();
		assert.equal( contents.length, 1, "Check object contents" );
		assert.equal( contents.find( "svg" ).length, 1, "Find svg within object" );
	} );

	jQuery( "#qunit-fixture" ).append( svgObject );
} );
emibloque added a commit to emibloque/jquery that referenced this issue Apr 18, 2018
@dmethvin dmethvin added this to the 3.4.0 milestone May 14, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Nov 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet

Successfully merging a pull request may close this issue.

2 participants