jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/376262 )

Change subject: ve.ce.Surface: Make attribute resolution consistent with 
ve.ui.PreviewElement
......................................................................


ve.ce.Surface: Make attribute resolution consistent with ve.ui.PreviewElement

Resolving attributes means turning 'href' and 'src' URLs from possibly
relative to absolute, so that they don't depend on the base URI of the
document.

ve.ce.Surface has incorrect code comments and only handles hrefs.
ve.ui.PreviewElement code was written later and is better. But also
add some FIXMEs there.

Change-Id: I058f00b28ef8c3e373816db325adafeaad750583
---
M src/ce/ve.ce.Surface.js
M src/ui/elements/ve.ui.PreviewElement.js
2 files changed, 13 insertions(+), 10 deletions(-)

Approvals:
  Esanders: Looks good to me, but someone else must approve
  Catrope: Looks good to me, approved
  jenkins-bot: Verified
  Jforrester: Looks good to me, but someone else must approve



diff --git a/src/ce/ve.ce.Surface.js b/src/ce/ve.ce.Surface.js
index 3b0c782..979cc89 100644
--- a/src/ce/ve.ce.Surface.js
+++ b/src/ce/ve.ce.Surface.js
@@ -1655,19 +1655,18 @@
        // by adding a dummy class, which we can remove after paste.
        this.$pasteTarget.find( 'span' ).addClass( 've-pasteProtect' );
 
-       // When paste has no text content browsers do extreme noramlization...
+       // When paste has no text content browsers do extreme normalization...
        if ( this.$pasteTarget.text() === '' ) {
                // ...so put nbsp's in empty leaves
                this.$pasteTarget.find( '*:not( :has( * ) )' ).html( ' ' );
        }
 
-       // href absolutization either doesn't occur (because we copy HTML to 
the clipboard
-       // directly with clipboardData#setData) or it resolves against the 
wrong document
-       // (window.document instead of ve.dm.Document#getHtmlDocument) so do it 
manually
-       // with ve#resolveUrl
-       this.$pasteTarget.find( 'a' ).attr( 'href', function ( i, href ) {
-               return ve.resolveUrl( href, htmlDoc );
-       } );
+       // Resolve attributes (in particular, expand 'href' and 'src' using the 
right base)
+       ve.resolveAttributes(
+               this.$pasteTarget[ 0 ],
+               htmlDoc,
+               ve.dm.Converter.static.computedAttributes
+       );
 
        // Support: Firefox
        // Some attributes (e.g RDFa attributes in Firefox) aren't preserved by 
copy
diff --git a/src/ui/elements/ve.ui.PreviewElement.js 
b/src/ui/elements/ve.ui.PreviewElement.js
index b2baaec..1dddeb3 100644
--- a/src/ui/elements/ve.ui.PreviewElement.js
+++ b/src/ui/elements/ve.ui.PreviewElement.js
@@ -65,11 +65,15 @@
  * @fires render
  */
 ve.ui.PreviewElement.prototype.replaceWithModelDom = function () {
-       var htmlDocument = ve.dm.converter.getDomFromNode( this.model, true ),
+       var
+               // FIXME: The 'true' means 'for clipboard'. This is not really 
true, but changing it to 'false'
+               // breaks the rendering of pretty much everything that checks 
for 'converter.isForClipboard()',
+               // e.g. nodes in MW like MWTransclusionNode and 
MWNumberedExternalLinkNode.
+               htmlDocument = ve.dm.converter.getDomFromNode( this.model, true 
),
                body = htmlDocument.body,
                element = this.$element[ 0 ];
 
-       // Resolve attributes
+       // Resolve attributes (in particular, expand 'href' and 'src' using the 
right base)
        ve.resolveAttributes(
                body,
                this.model.getDocument().getHtmlDocument(),

-- 
To view, visit https://gerrit.wikimedia.org/r/376262
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I058f00b28ef8c3e373816db325adafeaad750583
Gerrit-PatchSet: 3
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Bartosz DziewoƄski <matma....@gmail.com>
Gerrit-Reviewer: Catrope <r...@wikimedia.org>
Gerrit-Reviewer: Esanders <esand...@wikimedia.org>
Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to