mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 22:35:41 +00:00
Merge "Allow MediaWiki extensions to use self closing tags"
This commit is contained in:
commit
fb4bb65a74
|
@ -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 '<'. (bug 57429)
|
||||
value = value.replace( new RegExp( '<(/' + tagName + '\\s*>)', 'gi' ), '<$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;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue