diff --git a/modules/ve-cite/ve.ui.MWReferenceContextItem.js b/modules/ve-cite/ve.ui.MWReferenceContextItem.js
index 65563d3c1..b977f1e57 100644
--- a/modules/ve-cite/ve.ui.MWReferenceContextItem.js
+++ b/modules/ve-cite/ve.ui.MWReferenceContextItem.js
@@ -74,9 +74,10 @@ ve.ui.MWReferenceContextItem.prototype.getRendering = function () {
* @return {jQuery|null}
*/
ve.ui.MWReferenceContextItem.prototype.getReuseWarning = function () {
+ const refModel = ve.dm.MWReferenceModel.static.newFromReferenceNode( this.model );
const group = this.getFragment().getDocument().getInternalList()
- .getNodeGroup( this.model.getAttribute( 'listGroup' ) );
- const nodes = ve.getProp( group, 'keyedNodes', this.model.getAttribute( 'listKey' ) );
+ .getNodeGroup( refModel.getListGroup() );
+ const nodes = ve.getProp( group, 'keyedNodes', refModel.getListKey() );
const usages = nodes && nodes.filter( function ( node ) {
return !node.findParent( ve.dm.MWReferencesListNode );
} ).length;
@@ -94,7 +95,9 @@ ve.ui.MWReferenceContextItem.prototype.getReuseWarning = function () {
* @return {jQuery|null}
*/
ve.ui.MWReferenceContextItem.prototype.getExtendsWarning = function () {
- if ( this.model.getAttribute( 'extendsRef' ) ) {
+ const refModel = ve.dm.MWReferenceModel.static.newFromReferenceNode( this.model );
+
+ if ( refModel.extendsRef ) {
return $( '
' )
.addClass( 've-ui-mwReferenceContextItem-muted' )
.text( mw.msg( 'cite-ve-dialog-reference-editing-extends' ) );
@@ -111,8 +114,9 @@ ve.ui.MWReferenceContextItem.prototype.getReferenceNode = function () {
return null;
}
if ( !this.referenceNode ) {
+ const refModel = ve.dm.MWReferenceModel.static.newFromReferenceNode( this.model );
this.referenceNode = this.getFragment().getDocument().getInternalList()
- .getItemNode( this.model.getAttribute( 'listIndex' ) );
+ .getItemNode( refModel.getListIndex() );
}
return this.referenceNode;
};
@@ -131,12 +135,12 @@ ve.ui.MWReferenceContextItem.prototype.getDescription = function () {
* @return {string|null}
*/
ve.ui.MWReferenceContextItem.prototype.getParentRef = function () {
- const extendsRef = this.model.getAttribute( 'extendsRef' );
- if ( !extendsRef ) {
+ const refModel = ve.dm.MWReferenceModel.static.newFromReferenceNode( this.model );
+ if ( !refModel.extendsRef ) {
return null;
}
const list = this.getFragment().getDocument().getInternalList();
- const index = list.keys.indexOf( 'literal/' + extendsRef );
+ const index = list.keys.indexOf( 'literal/' + refModel.extendsRef );
return list.getItemNode( index ).element.attributes.originalHtml;
};
diff --git a/modules/ve-cite/ve.ui.MWReferenceDialog.js b/modules/ve-cite/ve.ui.MWReferenceDialog.js
index e6a85cc31..025a5f58e 100644
--- a/modules/ve-cite/ve.ui.MWReferenceDialog.js
+++ b/modules/ve-cite/ve.ui.MWReferenceDialog.js
@@ -197,7 +197,7 @@ ve.ui.MWReferenceDialog.prototype.onReferenceGroupInputChange = function () {
* @param {ve.ui.MWReferenceResultWidget} item Chosen item
*/
ve.ui.MWReferenceDialog.prototype.onSearchResultsChoose = function ( item ) {
- const ref = ve.dm.MWReferenceModel.static.newFromReferenceNode( item.getData() );
+ const ref = item.getData();
if ( this.selectedNode instanceof ve.dm.MWReferenceNode ) {
this.getFragment().removeContent();
diff --git a/modules/ve-cite/ve.ui.MWReferenceSearchWidget.js b/modules/ve-cite/ve.ui.MWReferenceSearchWidget.js
index d601491cb..f5f23a755 100644
--- a/modules/ve-cite/ve.ui.MWReferenceSearchWidget.js
+++ b/modules/ve-cite/ve.ui.MWReferenceSearchWidget.js
@@ -138,13 +138,13 @@ ve.ui.MWReferenceSearchWidget.prototype.buildIndex = function () {
}
// Only increment counter for real references
n++;
- const itemNode = this.internalList.getItemNode( refNode.getAttribute( 'listIndex' ) );
+ const refModel = ve.dm.MWReferenceModel.static.newFromReferenceNode( refNode );
+ const itemNode = this.internalList.getItemNode( refModel.getListIndex() );
- const refGroup = refNode.getAttribute( 'refGroup' );
+ const refGroup = refModel.getGroup();
const citation = ( refGroup && refGroup.length ? refGroup + ' ' : '' ) + n;
// Use [\s\S]* instead of .* to catch esoteric whitespace (T263698)
- // TODO: pass through mw-data name instead
- const matches = refNode.getAttribute( 'listKey' ).match( /^literal\/([\s\S]*)$/ );
+ const matches = refModel.getListKey().match( /^literal\/([\s\S]*)$/ );
const name = matches && matches[ 1 ] || '';
// TODO: At some point we need to make sure this text is updated in
@@ -172,7 +172,7 @@ ve.ui.MWReferenceSearchWidget.prototype.buildIndex = function () {
this.index.push( {
$element: $element,
text: text,
- reference: refNode,
+ reference: refModel,
citation: citation,
name: name
} );