Simplify toDataElement in MW

As per I54943588c5cc2 in core.

Change-Id: Ia40e7327c4ce07a79d64a6d5b1ff0d7acec55171
This commit is contained in:
Ed Sanders 2014-01-23 15:07:13 +00:00 committed by Roan Kattouw
parent c768b22bdd
commit bdb4a8a149
13 changed files with 6 additions and 34 deletions

View file

@ -37,7 +37,6 @@ ve.dm.MWExternalLinkAnnotation.static.matchRdfaTypes = [ 'mw:ExtLink' ];
ve.dm.MWExternalLinkAnnotation.static.toDataElement = function ( domElements ) {
var parentResult = ve.dm.LinkAnnotation.static.toDataElement.apply( this, arguments );
parentResult.type = 'link/mwExternal';
parentResult.attributes.rel = domElements[0].getAttribute( 'rel' );
return parentResult;
};

View file

@ -64,7 +64,7 @@ ve.dm.MWInternalLinkAnnotation.static.toDataElement = function ( domElements, co
normalizedTitle = ve.dm.MWInternalLinkAnnotation.static.normalizeTitle( matches[2] );
return {
'type': 'link/mwInternal',
'type': this.name,
'attributes': {
'hrefPrefix': matches[1],
'title': decodeURIComponent( matches[2] ).replace( /_/g, ' ' ),

View file

@ -33,7 +33,7 @@ ve.dm.MWNowikiAnnotation.static.matchRdfaTypes = [ 'mw:Nowiki' ];
ve.dm.MWNowikiAnnotation.static.toDataElement = function ( domElements ) {
return {
'type': 'mwNowiki',
'type': this.name,
'attributes': {
'originalDomElements': ve.copy( domElements )
}

View file

@ -38,7 +38,7 @@ ve.dm.MWCategoryMetaItem.static.toDataElement = function ( domElements ) {
matches = href.match( /^((?:\.\.?\/)*)(.*?)(?:#(.*))?$/ ),
rawSortkey = matches[3] || '';
return {
'type': 'mwCategory',
'type': this.name,
'attributes': {
'hrefPrefix': matches[1],
'category': decodeURIComponent( matches[2] ).replace( /_/g, ' ' ),

View file

@ -33,7 +33,7 @@ ve.dm.MWLanguageMetaItem.static.matchRdfaTypes = [ 'mw:PageProp/Language' ];
ve.dm.MWLanguageMetaItem.static.toDataElement = function ( domElements ) {
var href = domElements[0].getAttribute( 'href' );
return {
'type': 'mwLanguage',
'type': this.name,
'attributes': {
'href': href
}

View file

@ -32,10 +32,6 @@ ve.dm.MWNoEditSectionMetaItem.static.matchTagNames = [ 'meta' ];
ve.dm.MWNoEditSectionMetaItem.static.matchRdfaTypes = [ 'mw:PageProp/noeditsection' ];
ve.dm.MWNoEditSectionMetaItem.static.toDataElement = function () {
return { 'type': this.name };
};
ve.dm.MWNoEditSectionMetaItem.static.toDomElements = function ( dataElement, doc ) {
var meta = doc.createElement( 'meta' );
meta.setAttribute( 'property', 'mw:PageProp/noeditsection' );

View file

@ -32,10 +32,6 @@ ve.dm.MWTOCDisableMetaItem.static.matchTagNames = [ 'meta' ];
ve.dm.MWTOCDisableMetaItem.static.matchRdfaTypes = [ 'mw:PageProp/notoc' ];
ve.dm.MWTOCDisableMetaItem.static.toDataElement = function () {
return { 'type': this.name };
};
ve.dm.MWTOCDisableMetaItem.static.toDomElements = function ( dataElement, doc ) {
var meta = doc.createElement( 'meta' );
meta.setAttribute( 'property', 'mw:PageProp/notoc' );

View file

@ -32,10 +32,6 @@ ve.dm.MWTOCForceMetaItem.static.matchTagNames = [ 'meta' ];
ve.dm.MWTOCForceMetaItem.static.matchRdfaTypes = [ 'mw:PageProp/forcetoc' ];
ve.dm.MWTOCForceMetaItem.static.toDataElement = function () {
return { 'type': this.name };
};
ve.dm.MWTOCForceMetaItem.static.toDomElements = function ( dataElement, doc ) {
var meta = doc.createElement( 'meta' );
meta.setAttribute( 'property', 'mw:PageProp/forcetoc' );

View file

@ -34,7 +34,7 @@ ve.dm.MWEntityNode.static.matchTagNames = [ 'span' ];
ve.dm.MWEntityNode.static.matchRdfaTypes = [ 'mw:Entity' ];
ve.dm.MWEntityNode.static.toDataElement = function ( domElements ) {
return { 'type': 'mwEntity', 'attributes': { 'character': domElements[0].textContent } };
return { 'type': this.name, 'attributes': { 'character': domElements[0].textContent } };
};
ve.dm.MWEntityNode.static.toDomElements = function ( dataElement, doc ) {

View file

@ -29,12 +29,6 @@ ve.dm.MWHeadingNode.static.name = 'mwHeading';
ve.dm.MWHeadingNode.static.suggestedParentNodeTypes = [ 'document' ];
ve.dm.MWHeadingNode.static.toDataElement = function () {
var parentElement = ve.dm.HeadingNode.static.toDataElement.apply( this, arguments );
parentElement.type = 'mwHeading';
return parentElement;
};
/* Registration */
ve.dm.modelRegistry.register( ve.dm.MWHeadingNode );

View file

@ -27,11 +27,6 @@ ve.dm.MWImageCaptionNode.static.matchTagNames = [];
ve.dm.MWImageCaptionNode.static.parentNodeTypes = [ 'mwBlockImage' ];
ve.dm.MWImageCaptionNode.static.toDataElement = function () {
// Probably not needed
return { 'type': 'mwImageCaption' };
};
ve.dm.MWImageCaptionNode.static.toDomElements = function ( dataElement, doc ) {
return [ doc.createElement( 'figcaption' ) ];
};

View file

@ -40,7 +40,7 @@ ve.dm.MWNumberedExternalLinkNode.static.matchFunction = function ( element ) {
ve.dm.MWNumberedExternalLinkNode.static.toDataElement = function ( domElements ) {
return {
'type': 'link/mwNumberedExternal',
'type': this.name,
'attributes': {
'href': domElements[0].getAttribute( 'href' )
}

View file

@ -29,10 +29,6 @@ ve.dm.MWPreformattedNode.static.name = 'mwPreformatted';
ve.dm.MWPreformattedNode.static.suggestedParentNodeTypes = [ 'document' ];
ve.dm.MWPreformattedNode.static.toDataElement = function () {
return { 'type': 'mwPreformatted' };
};
/* Registration */
ve.dm.modelRegistry.register( ve.dm.MWPreformattedNode );