Fix detection of headings in NWE format menu

Use regex to include match any character after '='.

Bug: T147585
Change-Id: I22228bedf497613506a676eca465d3bc7bc5fe67
This commit is contained in:
Ed Sanders 2016-10-07 12:44:55 -04:00 committed by Jforrester
parent 7551b0e788
commit 3d39b80991

View file

@ -28,7 +28,7 @@ OO.inheritClass( ve.dm.MWWikitextSurfaceFragment, ve.dm.SourceSurfaceFragment );
* @inheritdoc
*/
ve.dm.MWWikitextSurfaceFragment.prototype.hasMatchingAncestor = function ( type, attributes ) {
var i, len, text, command,
var i, len, text,
nodes = this.getSelectedLeafNodes(),
all = !!nodes.length;
@ -48,10 +48,8 @@ ve.dm.MWWikitextSurfaceFragment.prototype.hasMatchingAncestor = function ( type,
all = text.slice( 0, 12 ) === '<blockquote>';
break;
case 'mwHeading':
command = ve.ui.wikitextCommandRegistry.lookup( 'heading' + attributes.level );
if ( text.indexOf( command.args[ 0 ] ) !== 0 || text.indexOf( command.args[ 1 ] ) !== text.length - command.args[ 1 ].length ) {
all = false;
}
all = text.match( new RegExp( '^={' + attributes.level + '}[^=]' ) ) &&
text.match( new RegExp( '[^=]={' + attributes.level + '}$' ) );
break;
default:
all = false;