Allow MediaWiki extensions to use self closing tags

Parsoid now supports this by setting body to null.

Change-Id: I24d856f0cffeacb00cb2b757e34315bc02b595d0
This commit is contained in:
Ed Sanders 2017-10-02 16:50:38 +01:00 committed by James D. Forrester
parent ddc056a40a
commit cd097bed3d

View file

@ -37,6 +37,17 @@ OO.initClass( ve.ui.MWExtensionWindow );
*/
ve.ui.MWExtensionWindow.static.allowedEmpty = false;
/**
* Tell Parsoid to self-close tags when the body is empty
*
* i.e. `<foo></foo>` -> `<foo/>`
*
* @static
* @property {boolean}
* @inheritable
*/
ve.ui.MWExtensionWindow.static.selfCloseEmptyBody = false;
/**
* Inspector's directionality, 'ltr' or 'rtl'
*
@ -242,6 +253,10 @@ ve.ui.MWExtensionWindow.prototype.updateMwData = function ( mwData ) {
// Prevent that by escaping the first angle bracket '<' to '&lt;'. (bug 57429)
value = value.replace( new RegExp( '<(/' + tagName + '\\s*>)', 'gi' ), '&lt;$1' );
mwData.body = mwData.body || {};
mwData.body.extsrc = value;
if ( value.trim() === '' && this.constructor.static.selfCloseEmptyBody ) {
mwData.body = null;
} else {
mwData.body = mwData.body || {};
mwData.body.extsrc = value;
}
};