Hygiene: Followup from 191fc2a

pass a collection of jQuery objects to `.append` instead of
and array.

Use `.css` instead of `.attr` to set thumbnail background image.

Change a unit to reflect the escaping pattern of the `.css` method

Bug: T219846
Change-Id: I6359be2db6c7c7a8e4b52296e0801d4ded921b46
This commit is contained in:
Jan Drewniak 2019-05-01 13:01:56 +02:00
parent a7e6c196f7
commit fcd4d1a272
2 changed files with 10 additions and 11 deletions

View file

@ -49,14 +49,13 @@
class: 'ext-related-articles-card'
} );
$listItem.append( [
$listItem.append(
$( '<div>' )
.attr( {
class: 'ext-related-articles-card-thumb',
style: attributes.hasThumbnail ?
'background-image: url( \'' + attributes.thumbnailUrl + '\' );' :
null
} ),
.addClass( 'ext-related-articles-card-thumb' )
.css( 'background-image', attributes.hasThumbnail ?
'url(' + attributes.thumbnailUrl + ')' :
null
),
$( '<a>' )
.attr( {
href: attributes.url,
@ -65,7 +64,7 @@
} ),
$( '<div>' )
.attr( { class: 'ext-related-articles-card-detail' } )
.append( [
.append(
$( '<h3>' ).append(
$( '<a>' )
.attr( { href: attributes.url } )
@ -74,8 +73,8 @@
$( '<p>' )
.attr( { class: 'ext-related-articles-card-extract' } )
.text( attributes.extract )
] )
] );
)
);
return $listItem;
};

View file

@ -23,7 +23,7 @@
assert.strictEqual(
style,
'background-image: url( \'http\\:\\/\\/foo\\.bar\\/\\\'\\)\\;display\\:none\\;\\"\\/\\/baz\\.jpg\' );'
"background-image: url(\"http://foo.bar/');display:none;\\\"//baz.jpg\");"
);
} );
}() );