Revert "Parse relative hrefs on image nodes like on regular links"

This reverts commit 6037fefbe0.
This reverts commit da9b6fffbd.

Bug: T237040
Change-Id: Id6ea5784512e4d4c3cb00927b859d713c3814f89
This commit is contained in:
Bartosz Dziewoński 2019-10-31 22:24:13 +01:00
parent f24c823212
commit 00eb79d4d7
7 changed files with 54 additions and 80 deletions

View file

@ -82,7 +82,7 @@ ve.ce.MWGalleryImageNode = function VeCeMWGalleryImageNode( model ) {
.attr( 'width', attributes.width );
this.$filenameA = $( '<a>' )
.attr( 'href', '#' ) // Just to make it look like a link
.text( mw.Title.newFromText( ve.normalizeParsoidResourceName( attributes.resource ) ).getMainText() )
.text( mw.Title.newFromText( attributes.resource ).getMainText() )
.toggleClass( 'oo-ui-element-hidden', galleryMwAttrs.showfilename !== 'yes' );
this.$element.prepend(

View file

@ -68,7 +68,7 @@ ve.dm.MWBlockImageNode.static.classAttributes = {
ve.dm.MWBlockImageNode.static.toDataElement = function ( domElements, converter ) {
var dataElement, newDimensions, attributes,
figure, imgWrapper, img, captionNode, caption,
classAttr, typeofAttrs, errorIndex, width, height, href, targetData, resource, types,
classAttr, typeofAttrs, errorIndex, width, height, types,
mwDataJSON, mwData;
figure = domElements[ 0 ];
@ -83,19 +83,6 @@ ve.dm.MWBlockImageNode.static.toDataElement = function ( domElements, converter
width = img.getAttribute( 'width' );
height = img.getAttribute( 'height' );
href = imgWrapper.getAttribute( 'href' );
if ( href ) {
// Convert absolute URLs to relative if the href refers to a page on this wiki.
// Otherwise Parsoid generates |link= options for copy-pasted images (T193253).
targetData = ve.dm.MWInternalLinkAnnotation.static.getTargetDataFromHref( href, converter.getTargetHtmlDocument() );
if ( targetData.isInternal ) {
href = './' + targetData.title;
}
}
// Ensure that resource and href are identical if they refer to the same page.
// https://www.mediawiki.org/w/?diff=931265&oldid=prev
resource = './' + ve.normalizeParsoidResourceName( img.getAttribute( 'resource' ) );
if ( errorIndex !== -1 ) {
typeofAttrs.splice( errorIndex, 1 );
}
@ -106,8 +93,8 @@ ve.dm.MWBlockImageNode.static.toDataElement = function ( domElements, converter
mediaClass: types.mediaClass,
type: types.frameType,
src: img.getAttribute( 'src' ) || img.getAttribute( 'poster' ),
href: href,
resource: resource,
href: imgWrapper.getAttribute( 'href' ),
resource: img.getAttribute( 'resource' ),
width: width !== null && width !== '' ? +width : null,
height: height !== null && height !== '' ? +height : null,
alt: img.getAttribute( 'alt' ),

View file

@ -72,7 +72,7 @@ ve.dm.MWGalleryImageNode.static.toDataElement = function ( domElements, converte
dataElement = {
type: this.name,
attributes: {
resource: './' + ve.normalizeParsoidResourceName( img.getAttribute( 'resource' ) ),
resource: ve.normalizeParsoidResourceName( img.getAttribute( 'resource' ) ),
altText: img.getAttribute( 'alt' ),
// 'src' for images, 'poster' for video/audio
src: img.getAttribute( 'src' ) || img.getAttribute( 'poster' ),

View file

@ -51,7 +51,7 @@ ve.dm.MWInlineImageNode.static.matchTagNames = [ 'span', 'figure-inline' ];
ve.dm.MWInlineImageNode.static.blacklistedAnnotationTypes = [ 'link' ];
ve.dm.MWInlineImageNode.static.toDataElement = function ( domElements, converter ) {
var dataElement, attributes, href, targetData, resource, types,
var dataElement, attributes, types,
figureInline = domElements[ 0 ],
imgWrapper = figureInline.children[ 0 ], // <a> or <span>
img = imgWrapper.children[ 0 ], // <img>, <video> or <audio>
@ -64,19 +64,6 @@ ve.dm.MWInlineImageNode.static.toDataElement = function ( domElements, converter
width = img.getAttribute( 'width' ),
height = img.getAttribute( 'height' );
href = imgWrapper.getAttribute( 'href' );
if ( href ) {
// Convert absolute URLs to relative if the href refers to a page on this wiki.
// Otherwise Parsoid generates |link= options for copy-pasted images (T193253).
targetData = ve.dm.MWInternalLinkAnnotation.static.getTargetDataFromHref( href, converter.getTargetHtmlDocument() );
if ( targetData.isInternal ) {
href = './' + targetData.title;
}
}
// Ensure that resource and href are identical if they refer to the same page.
// https://www.mediawiki.org/w/?diff=931265&oldid=prev
resource = './' + ve.normalizeParsoidResourceName( img.getAttribute( 'resource' ) );
if ( errorIndex !== -1 ) {
typeofAttrs.splice( errorIndex, 1 );
}
@ -87,8 +74,8 @@ ve.dm.MWInlineImageNode.static.toDataElement = function ( domElements, converter
mediaClass: types.mediaClass,
type: types.frameType,
src: img.getAttribute( 'src' ) || img.getAttribute( 'poster' ),
href: href,
resource: resource,
href: imgWrapper.getAttribute( 'href' ),
resource: img.getAttribute( 'resource' ),
originalClasses: classes,
width: width !== null && width !== '' ? +width : null,
height: height !== null && height !== '' ? +height : null,

View file

@ -271,7 +271,7 @@ ve.dm.mwExample.MWMediaLinkMissingData = {
ve.dm.mwExample.MWBlockImage = {
html:
'<figure typeof="mw:Image/Thumb" class="mw-halign-right foobar">' +
'<a href="./Foo"><img src="' + ve.ce.minImgDataUri + '" width="1" height="2" resource="./FooBar" alt="alt text"></a>' +
'<a href="Foo"><img src="' + ve.ce.minImgDataUri + '" width="1" height="2" resource="FooBar" alt="alt text"></a>' +
'<figcaption>abc</figcaption>' +
'</figure>',
data: [
@ -280,14 +280,14 @@ ve.dm.mwExample.MWBlockImage = {
attributes: {
type: 'thumb',
align: 'right',
href: './Foo',
href: 'Foo',
mediaClass: 'Image',
src: ve.ce.minImgDataUri,
width: 1,
height: 2,
alt: 'alt text',
isError: false,
resource: './FooBar',
resource: 'FooBar',
mw: {},
originalClasses: 'mw-halign-right foobar',
unrecognizedClasses: [ 'foobar' ]
@ -301,7 +301,7 @@ ve.dm.mwExample.MWBlockImage = {
{ type: '/mwBlockImage' }
],
storeItems: {
h1d9b405cfd633576: ve.ce.minImgDataUri
h5ca4c84da870e58f: ve.ce.minImgDataUri
}
};
@ -803,7 +803,7 @@ ve.dm.mwExample.domToDataCases = {
normalizedBody: '<table><tr><td>Foo</td></tr></table>'
},
'mwGalleryImage (no caption in DOM)': {
body: '<ul class="gallery mw-gallery-packed-hover" typeof="mw:Extension/gallery" data-mw=\'{"attrs":{"mode":"packed-hover"},"body":{"extsrc":""},"name":"gallery"}\'><li class="gallerybox" style="width: 122px;"><div class="thumb" style="width: 120px;"><figure-inline typeof="mw:Image"><a href="./Foo"><img resource="./Foo" src="' + ve.ce.minImgDataUri + '" height="120" width="120"/></a></figure-inline></div></li></ul>',
body: '<ul class="gallery mw-gallery-packed-hover" typeof="mw:Extension/gallery" data-mw=\'{"attrs":{"mode":"packed-hover"},"body":{"extsrc":""},"name":"gallery"}\'><li class="gallerybox" style="width: 122px;"><div class="thumb" style="width: 120px;"><figure-inline typeof="mw:Image"><a href="Foo"><img resource="Foo" src="' + ve.ce.minImgDataUri + '" height="120" width="120"/></a></figure-inline></div></li></ul>',
data: [
{
type: 'mwGallery',
@ -825,7 +825,7 @@ ve.dm.mwExample.domToDataCases = {
attributes: {
altText: null,
height: '120',
resource: './Foo',
resource: 'Foo',
src: ve.ce.minImgDataUri,
width: '120'
}
@ -844,11 +844,11 @@ ve.dm.mwExample.domToDataCases = {
{ type: 'internalList' },
{ type: '/internalList' }
],
normalizedBody: '<ul class="gallery" typeof="mw:Extension/gallery" data-mw=\'{"attrs":{"mode":"packed-hover"},"body":{"extsrc":""},"name":"gallery"}\'><li class="gallerybox" style="width: 122px;"><div><div class="thumb"><div><a><img resource="./Foo" src="' + ve.ce.minImgDataUri + '"/></a></div></div></div><div class="gallerytext"></div></li></ul>',
fromDataBody: '<ul class="gallery" typeof="mw:Extension/gallery" data-mw=\'{"attrs":{"mode":"packed-hover"},"body":{"extsrc":""},"name":"gallery"}\'><li class="gallerybox"><div><div class="thumb"><div><a><img resource="./Foo" src="' + ve.ce.minImgDataUri + '"/></a></div></div></div><div class="gallerytext"></div></li></ul>'
normalizedBody: '<ul class="gallery" typeof="mw:Extension/gallery" data-mw=\'{"attrs":{"mode":"packed-hover"},"body":{"extsrc":""},"name":"gallery"}\'><li class="gallerybox" style="width: 122px;"><div><div class="thumb"><div><a><img resource="Foo" src="' + ve.ce.minImgDataUri + '"/></a></div></div></div><div class="gallerytext"></div></li></ul>',
fromDataBody: '<ul class="gallery" typeof="mw:Extension/gallery" data-mw=\'{"attrs":{"mode":"packed-hover"},"body":{"extsrc":""},"name":"gallery"}\'><li class="gallerybox"><div><div class="thumb"><div><a><img resource="Foo" src="' + ve.ce.minImgDataUri + '"/></a></div></div></div><div class="gallerytext"></div></li></ul>'
},
'mwGalleryImage (empty caption in DOM)': {
body: '<ul class="gallery mw-gallery-packed" typeof="mw:Extension/gallery" data-mw=\'{"attrs":{"mode":"packed"},"body":{"extsrc":""},"name":"gallery"}\'><li class="gallerybox" style="width: 122px;"><div class="thumb" style="width: 120px;"><figure-inline typeof="mw:Image"><a href="./Foo"><img resource="./Foo" src="' + ve.ce.minImgDataUri + '" height="120" width="120"/></a></figure-inline></div><div class="gallerytext"></div></li></ul>',
body: '<ul class="gallery mw-gallery-packed" typeof="mw:Extension/gallery" data-mw=\'{"attrs":{"mode":"packed"},"body":{"extsrc":""},"name":"gallery"}\'><li class="gallerybox" style="width: 122px;"><div class="thumb" style="width: 120px;"><figure-inline typeof="mw:Image"><a href="Foo"><img resource="Foo" src="' + ve.ce.minImgDataUri + '" height="120" width="120"/></a></figure-inline></div><div class="gallerytext"></div></li></ul>',
data: [
{
type: 'mwGallery',
@ -870,7 +870,7 @@ ve.dm.mwExample.domToDataCases = {
attributes: {
altText: null,
height: '120',
resource: './Foo',
resource: 'Foo',
src: ve.ce.minImgDataUri,
width: '120'
}
@ -889,11 +889,11 @@ ve.dm.mwExample.domToDataCases = {
{ type: 'internalList' },
{ type: '/internalList' }
],
normalizedBody: '<ul class="gallery" typeof="mw:Extension/gallery" data-mw=\'{"attrs":{"mode":"packed"},"body":{"extsrc":""},"name":"gallery"}\'><li class="gallerybox" style="width: 122px;"><div><div class="thumb"><div><a><img resource="./Foo" src="' + ve.ce.minImgDataUri + '"/></a></div></div></div><div class="gallerytext"></div></li></ul>',
fromDataBody: '<ul class="gallery" typeof="mw:Extension/gallery" data-mw=\'{"attrs":{"mode":"packed"},"body":{"extsrc":""},"name":"gallery"}\'><li class="gallerybox"><div><div class="thumb"><div><a><img resource="./Foo" src="' + ve.ce.minImgDataUri + '"/></a></div></div></div><div class="gallerytext"></div></li></ul>'
normalizedBody: '<ul class="gallery" typeof="mw:Extension/gallery" data-mw=\'{"attrs":{"mode":"packed"},"body":{"extsrc":""},"name":"gallery"}\'><li class="gallerybox" style="width: 122px;"><div><div class="thumb"><div><a><img resource="Foo" src="' + ve.ce.minImgDataUri + '"/></a></div></div></div><div class="gallerytext"></div></li></ul>',
fromDataBody: '<ul class="gallery" typeof="mw:Extension/gallery" data-mw=\'{"attrs":{"mode":"packed"},"body":{"extsrc":""},"name":"gallery"}\'><li class="gallerybox"><div><div class="thumb"><div><a><img resource="Foo" src="' + ve.ce.minImgDataUri + '"/></a></div></div></div><div class="gallerytext"></div></li></ul>'
},
'mwGalleryImage (caption with content in DOM)': {
body: '<ul class="gallery mw-gallery-packed" typeof="mw:Extension/gallery" data-mw=\'{"attrs":{"mode":"packed"},"body":{"extsrc":""},"name":"gallery"}\'><li class="gallerybox" style="width: 122px;"><div class="thumb" style="width: 120px;"><figure-inline typeof="mw:Image"><a href="./Foo"><img resource="./Foo" src="' + ve.ce.minImgDataUri + '" height="120" width="120"/></a></figure-inline></div><div class="gallerytext">Caption</div></li></ul>',
body: '<ul class="gallery mw-gallery-packed" typeof="mw:Extension/gallery" data-mw=\'{"attrs":{"mode":"packed"},"body":{"extsrc":""},"name":"gallery"}\'><li class="gallerybox" style="width: 122px;"><div class="thumb" style="width: 120px;"><figure-inline typeof="mw:Image"><a href="Foo"><img resource="Foo" src="' + ve.ce.minImgDataUri + '" height="120" width="120"/></a></figure-inline></div><div class="gallerytext">Caption</div></li></ul>',
data: [
{
type: 'mwGallery',
@ -915,7 +915,7 @@ ve.dm.mwExample.domToDataCases = {
attributes: {
altText: null,
height: '120',
resource: './Foo',
resource: 'Foo',
src: ve.ce.minImgDataUri,
width: '120'
}
@ -935,8 +935,8 @@ ve.dm.mwExample.domToDataCases = {
{ type: 'internalList' },
{ type: '/internalList' }
],
normalizedBody: '<ul class="gallery" typeof="mw:Extension/gallery" data-mw=\'{"attrs":{"mode":"packed"},"body":{"extsrc":""},"name":"gallery"}\'><li class="gallerybox" style="width: 122px;"><div><div class="thumb"><div><a><img resource="./Foo" src="' + ve.ce.minImgDataUri + '"/></a></div></div></div><div class="gallerytext">Caption</div></li></ul>',
fromDataBody: '<ul class="gallery" typeof="mw:Extension/gallery" data-mw=\'{"attrs":{"mode":"packed"},"body":{"extsrc":""},"name":"gallery"}\'><li class="gallerybox"><div><div class="thumb"><div><a><img resource="./Foo" src="' + ve.ce.minImgDataUri + '"/></a></div></div></div><div class="gallerytext">Caption</div></li></ul>'
normalizedBody: '<ul class="gallery" typeof="mw:Extension/gallery" data-mw=\'{"attrs":{"mode":"packed"},"body":{"extsrc":""},"name":"gallery"}\'><li class="gallerybox" style="width: 122px;"><div><div class="thumb"><div><a><img resource="Foo" src="' + ve.ce.minImgDataUri + '"/></a></div></div></div><div class="gallerytext">Caption</div></li></ul>',
fromDataBody: '<ul class="gallery" typeof="mw:Extension/gallery" data-mw=\'{"attrs":{"mode":"packed"},"body":{"extsrc":""},"name":"gallery"}\'><li class="gallerybox"><div><div class="thumb"><div><a><img resource="Foo" src="' + ve.ce.minImgDataUri + '"/></a></div></div></div><div class="gallerytext">Caption</div></li></ul>'
},
'mwGalleryImage (no caption in model)': {
data: [
@ -960,7 +960,7 @@ ve.dm.mwExample.domToDataCases = {
attributes: {
altText: null,
height: '120',
resource: './Foo',
resource: 'Foo',
src: ve.ce.minImgDataUri,
width: '120'
}
@ -970,7 +970,7 @@ ve.dm.mwExample.domToDataCases = {
{ type: 'internalList' },
{ type: '/internalList' }
],
fromDataBody: '<ul class="gallery" typeof="mw:Extension/gallery" data-mw=\'{"attrs":{"mode":"packed"},"body":{"extsrc":""},"name":"gallery"}\'><li class="gallerybox"><div><div class="thumb"><div><a><img resource="./Foo" src="' + ve.ce.minImgDataUri + '"/></a></div></div></div></li></ul>'
fromDataBody: '<ul class="gallery" typeof="mw:Extension/gallery" data-mw=\'{"attrs":{"mode":"packed"},"body":{"extsrc":""},"name":"gallery"}\'><li class="gallerybox"><div><div class="thumb"><div><a><img resource="Foo" src="' + ve.ce.minImgDataUri + '"/></a></div></div></div></li></ul>'
},
'mwGalleryImage (empty caption in model)': {
data: [
@ -994,7 +994,7 @@ ve.dm.mwExample.domToDataCases = {
attributes: {
altText: null,
height: '120',
resource: './Foo',
resource: 'Foo',
src: ve.ce.minImgDataUri,
width: '120'
}
@ -1006,10 +1006,10 @@ ve.dm.mwExample.domToDataCases = {
{ type: 'internalList' },
{ type: '/internalList' }
],
fromDataBody: '<ul class="gallery" typeof="mw:Extension/gallery" data-mw=\'{"attrs":{"mode":"packed"},"body":{"extsrc":""},"name":"gallery"}\'><li class="gallerybox"><div><div class="thumb"><div><a><img resource="./Foo" src="' + ve.ce.minImgDataUri + '"/></a></div></div></div><div class="gallerytext"></div></li></ul>'
fromDataBody: '<ul class="gallery" typeof="mw:Extension/gallery" data-mw=\'{"attrs":{"mode":"packed"},"body":{"extsrc":""},"name":"gallery"}\'><li class="gallerybox"><div><div class="thumb"><div><a><img resource="Foo" src="' + ve.ce.minImgDataUri + '"/></a></div></div></div><div class="gallerytext"></div></li></ul>'
},
'mwBlockImage (no caption in DOM)': {
body: '<figure typeof="mw:Image/Thumb"><a href="./Foo"><img resource="./Foo" src="' + ve.ce.minImgDataUri + '" height="300" width="300"/></a></figure>',
body: '<figure typeof="mw:Image/Thumb"><a href="Foo"><img resource="Foo" src="' + ve.ce.minImgDataUri + '" height="300" width="300"/></a></figure>',
data: [
{
type: 'mwBlockImage',
@ -1017,11 +1017,11 @@ ve.dm.mwExample.domToDataCases = {
align: 'default',
alt: null,
height: 300,
href: './Foo',
href: 'Foo',
isError: false,
mediaClass: 'Image',
mw: {},
resource: './Foo',
resource: 'Foo',
src: 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=',
type: 'thumb',
width: 300
@ -1040,10 +1040,10 @@ ve.dm.mwExample.domToDataCases = {
{ type: 'internalList' },
{ type: '/internalList' }
],
normalizedBody: '<figure typeof="mw:Image/Thumb"><a href="./Foo"><img resource="./Foo" src="' + ve.ce.minImgDataUri + '" height="300" width="300"/></a><figcaption></figcaption></figure>'
normalizedBody: '<figure typeof="mw:Image/Thumb"><a href="Foo"><img resource="Foo" src="' + ve.ce.minImgDataUri + '" height="300" width="300"/></a><figcaption></figcaption></figure>'
},
'mwBlockImage (empty caption in DOM)': {
body: '<figure typeof="mw:Image/Thumb"><a href="./Foo"><img resource="./Foo" src="' + ve.ce.minImgDataUri + '" height="300" width="300"/></a><figcaption></figcaption></figure>',
body: '<figure typeof="mw:Image/Thumb"><a href="Foo"><img resource="Foo" src="' + ve.ce.minImgDataUri + '" height="300" width="300"/></a><figcaption></figcaption></figure>',
data: [
{
type: 'mwBlockImage',
@ -1051,11 +1051,11 @@ ve.dm.mwExample.domToDataCases = {
align: 'default',
alt: null,
height: 300,
href: './Foo',
href: 'Foo',
isError: false,
mediaClass: 'Image',
mw: {},
resource: './Foo',
resource: 'Foo',
src: 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=',
type: 'thumb',
width: 300
@ -1076,7 +1076,7 @@ ve.dm.mwExample.domToDataCases = {
]
},
'mwBlockImage (caption with content in DOM)': {
body: '<figure typeof="mw:Image/Thumb"><a href="./Foo"><img resource="./Foo" src="' + ve.ce.minImgDataUri + '" height="300" width="300"/></a><figcaption>Caption</figcaption></figure>',
body: '<figure typeof="mw:Image/Thumb"><a href="Foo"><img resource="Foo" src="' + ve.ce.minImgDataUri + '" height="300" width="300"/></a><figcaption>Caption</figcaption></figure>',
data: [
{
type: 'mwBlockImage',
@ -1084,11 +1084,11 @@ ve.dm.mwExample.domToDataCases = {
align: 'default',
alt: null,
height: 300,
href: './Foo',
href: 'Foo',
isError: false,
mediaClass: 'Image',
mw: {},
resource: './Foo',
resource: 'Foo',
src: 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=',
type: 'thumb',
width: 300
@ -1117,11 +1117,11 @@ ve.dm.mwExample.domToDataCases = {
align: 'default',
alt: null,
height: 300,
href: './Foo',
href: 'Foo',
isError: false,
mediaClass: 'Image',
mw: {},
resource: './Foo',
resource: 'Foo',
src: 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=',
type: 'thumb',
width: 300
@ -1131,7 +1131,7 @@ ve.dm.mwExample.domToDataCases = {
{ type: 'internalList' },
{ type: '/internalList' }
],
fromDataBody: '<figure typeof="mw:Image/Thumb"><a href="./Foo"><img resource="./Foo" src="' + ve.ce.minImgDataUri + '" height="300" width="300"/></a></figure>'
fromDataBody: '<figure typeof="mw:Image/Thumb"><a href="Foo"><img resource="Foo" src="' + ve.ce.minImgDataUri + '" height="300" width="300"/></a></figure>'
},
'mwBlockImage (empty caption in model)': {
data: [
@ -1141,11 +1141,11 @@ ve.dm.mwExample.domToDataCases = {
align: 'default',
alt: null,
height: 300,
href: './Foo',
href: 'Foo',
isError: false,
mediaClass: 'Image',
mw: {},
resource: './Foo',
resource: 'Foo',
src: 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=',
type: 'thumb',
width: 300
@ -1157,7 +1157,7 @@ ve.dm.mwExample.domToDataCases = {
{ type: 'internalList' },
{ type: '/internalList' }
],
fromDataBody: '<figure typeof="mw:Image/Thumb"><a href="./Foo"><img resource="./Foo" src="' + ve.ce.minImgDataUri + '" height="300" width="300"/></a></figure>'
fromDataBody: '<figure typeof="mw:Image/Thumb"><a href="Foo"><img resource="Foo" src="' + ve.ce.minImgDataUri + '" height="300" width="300"/></a></figure>'
},
'mw:Transclusion (block level)': {
body: ve.dm.mwExample.MWTransclusion.blockOpen + ve.dm.mwExample.MWTransclusion.blockContent,
@ -1856,8 +1856,8 @@ ve.dm.mwExample.domToDataCases = {
'attribute preservation does not crash due to text node split': {
body:
'<figure typeof="mw:Image/Thumb" data-parsoid="{}">' +
'<a href="./Foo" data-parsoid="{}">' +
'<img src="' + ve.ce.minImgDataUri + '" width="1" height="2" resource="./FooBar" data-parsoid="{}">' +
'<a href="Foo" data-parsoid="{}">' +
'<img src="' + ve.ce.minImgDataUri + '" width="1" height="2" resource="FooBar" data-parsoid="{}">' +
'</a>' +
'<figcaption data-parsoid="{}">' +
' foo <a rel="mw:WikiLink" href="./Bar" data-parsoid="{}">bar</a> baz' +
@ -1865,8 +1865,8 @@ ve.dm.mwExample.domToDataCases = {
'</figure>',
fromDataBody:
'<figure typeof="mw:Image/Thumb">' +
'<a href="./Foo">' +
'<img src="' + ve.ce.minImgDataUri + '" width="1" height="2" resource="./FooBar">' +
'<a href="Foo">' +
'<img src="' + ve.ce.minImgDataUri + '" width="1" height="2" resource="FooBar">' +
'</a>' +
'<figcaption>' +
' foo <a rel="mw:WikiLink" href="./Bar">bar</a> baz' +
@ -1879,7 +1879,7 @@ ve.dm.mwExample.domToDataCases = {
attributes: {
type: 'thumb',
align: 'default',
href: './Foo',
href: 'Foo',
mediaClass: 'Image',
src: ve.ce.minImgDataUri,
width: 1,
@ -1887,7 +1887,7 @@ ve.dm.mwExample.domToDataCases = {
alt: null,
mw: {},
isError: false,
resource: './FooBar'
resource: 'FooBar'
}
},
{ type: 'mwImageCaption', internal: { whitespace: [ undefined, ' ' ] } },

View file

@ -34,7 +34,7 @@ QUnit.test( 'Diffing', function ( assert ) {
'<div class="ve-ui-diffElement-doc-child-change">' +
ve.dm.mwExample.MWBlockImage.html
.replace( 'width="1"', 'width="3"' )
.replace( 'href="./Foo"', 'href="' + ve.resolveUrl( './Foo', ve.dm.example.base ) + '"' )
.replace( 'href="Foo"', 'href="' + ve.resolveUrl( 'Foo', ve.dm.example.base ) + '"' )
.replace( 'foobar"', 'foobar" data-diff-action="structural-change" data-diff-id="0"' ) +
'</div>',
expectedDescriptions: [

View file

@ -416,7 +416,7 @@ ve.ui.MWGalleryDialog.prototype.getSetupProcess = function ( data ) {
for ( i = 0, ilen = imageNodes.length; i < ilen; i++ ) {
image = imageNodes[ i ];
resource = mw.Title.newFromText( ve.normalizeParsoidResourceName( image.getAttribute( 'resource' ) ), namespaceIds.file ).getPrefixedText();
resource = mw.Title.newFromText( image.getAttribute( 'resource' ), namespaceIds.file ).getPrefixedText();
imageCaptionNode = image.getCaptionNode();
imageTitles.push( resource );
this.initialImageData.push( {
@ -781,7 +781,7 @@ ve.ui.MWGalleryDialog.prototype.onHighlightItem = function ( item ) {
OO.ui.Element.static.scrollIntoView( item.$element[ 0 ] );
// Populate edit panel
title = mw.Title.newFromText( ve.normalizeParsoidResourceName( item.resource ) );
title = mw.Title.newFromText( item.resource );
this.filenameFieldset.setLabel(
$( '<span>' ).append(
document.createTextNode( title.getMainText() + ' ' ),
@ -997,7 +997,7 @@ ve.ui.MWGalleryDialog.prototype.insertOrUpdateNode = function () {
parseInt( mwData.attrs.widths || this.defaults.imageWidth )
);
imageAttributes = {
resource: './' + image.resource,
resource: image.resource,
altText: image.altText,
src: image.thumbUrl,
height: size.height,