mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +00:00
Throw an exception when attempting to annotate a closing element
Change-Id: Ifd4e49ee05e74db8bec754a6c1f79c969c1f2eac
This commit is contained in:
parent
5aa6f4b342
commit
5e6713eae5
|
@ -115,8 +115,12 @@ ve.dm.TransactionProcessor.prototype.applyAnnotations = function( to ) {
|
|||
for ( var i = this.cursor; i < to; i++ ) {
|
||||
item = this.document.data[i];
|
||||
element = item.type !== undefined;
|
||||
if ( element && ve.dm.nodeFactory.canNodeHaveChildren( item.type ) ) {
|
||||
throw 'Invalid transaction, can not annotate a branch element';
|
||||
if ( element ) {
|
||||
if ( item.type.charAt( 0 ) === '/' ) {
|
||||
throw 'Invalid transaction, cannot annotate a branch closing element';
|
||||
} else if ( ve.dm.nodeFactory.canNodeHaveChildren( item.type ) ) {
|
||||
throw 'Invalid transaction, cannot annotate a branch opening element';
|
||||
}
|
||||
}
|
||||
annotated = element ? 'annotations' in item : ve.isArray( item );
|
||||
annotations = annotated ? ( element ? item.annotations : item[1] ) : {};
|
||||
|
|
Loading…
Reference in a new issue