Skip to content

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

@emibloque

Description

@emibloque

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

Description

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(){
	svgObject.contents().find('svg');
})

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" );
		done();
	} );

	jQuery( "#qunit-fixture" ).append( svgObject );
} );

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions