Santhosh has uploaded a new change for review.
https://gerrit.wikimedia.org/r/230991
Change subject: Images: validate image id before adapting to prevent js error
......................................................................
Images: validate image id before adapting to prevent js error
Images not having an identifier can cause js error and can even
prevent any auto save happening further.
Testplan:
Translate enwiki:Amblydoras to es. Add the last section about
stub article. Console will show a js error and adding any other
secton after this won't trigger autosave. With this patch, there
should not be a js error and save should work as expected.
Change-Id: I18affd6927d391469db9e1c6445fa98a4f760f5c
---
M modules/tools/ext.cx.tools.images.js
1 file changed, 6 insertions(+), 2 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation
refs/changes/91/230991/1
diff --git a/modules/tools/ext.cx.tools.images.js
b/modules/tools/ext.cx.tools.images.js
index 08a7190..bb10b82 100644
--- a/modules/tools/ext.cx.tools.images.js
+++ b/modules/tools/ext.cx.tools.images.js
@@ -92,10 +92,14 @@
var targetLanguage = mw.cx.targetLanguage;
$section.find( 'img' ).each( function () {
- var $sourceSection, $sourceImage, $image = $( this );
+ var imageId, $sourceSection, $sourceImage, $image = $(
this );
+ imageId = $image.prop( 'id' );
+ if ( !imageId ) {
+ return;
+ }
$sourceSection = mw.cx.getSourceSection( $section.data(
'source' ) );
- $sourceImage = $sourceSection.find( '#' + $image.prop(
'id' ) );
+ $sourceImage = $sourceSection.find( '#' + imageId );
$image.on( 'click', function ( event ) {
// Avoid opening images by clicking.
event.preventDefault();
--
To view, visit https://gerrit.wikimedia.org/r/230991
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I18affd6927d391469db9e1c6445fa98a4f760f5c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits