MWExternalLinkAnnotation: Only match plain external <a>s with hrefs

We now accept non-Parsoid generated external links from paste,
so make sure they have href attributes otherwise they aren't
really external links and will throw exceptions later on.

Bug: T131430
Change-Id: Ifb565b1ce30cfe80ae72b17f6a9551ea40b36453
This commit is contained in:
Ed Sanders 2016-04-02 18:29:38 +03:00 committed by James D. Forrester
parent 4dadaa677c
commit 6fad9ecdee

View file

@ -35,8 +35,8 @@ ve.dm.MWExternalLinkAnnotation.static.name = 'link/mwExternal';
ve.dm.MWExternalLinkAnnotation.static.matchFunction = function ( domElement ) {
var rel = domElement.getAttribute( 'rel' );
// Match explicity mw:ExtLink, or plain RDFa-less links (e.g. from external paste)
return !rel || rel === 'mw:ExtLink';
// Match explicity mw:ExtLink, or plain RDFa-less links with an href (e.g. from external paste)
return ( !rel && domElement.hasAttribute( 'href' ) ) || rel === 'mw:ExtLink';
};
ve.dm.MWExternalLinkAnnotation.static.toDataElement = function ( domElements, converter ) {