jenkins-bot has submitted this change and it was merged.

Change subject: Use a detached icon in transclusion node
......................................................................


Use a detached icon in transclusion node

In the case the node is empty and we need an icon, use a separate
icon element that is detached and reattached as needed.

Change-Id: I5bcbe531cb1db1a4ac25ed4a2f462dde08513b7b
---
M modules/ve-mw/ce/nodes/ve.ce.MWTransclusionNode.js
M modules/ve-mw/ce/styles/nodes/ve.ce.MWTransclusionNode.css
2 files changed, 17 insertions(+), 5 deletions(-)

Approvals:
  Jforrester: Looks good to me, approved
  Trevor Parscal: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/ve-mw/ce/nodes/ve.ce.MWTransclusionNode.js 
b/modules/ve-mw/ce/nodes/ve.ce.MWTransclusionNode.js
index 04ad557..6c0ad68 100644
--- a/modules/ve-mw/ce/nodes/ve.ce.MWTransclusionNode.js
+++ b/modules/ve-mw/ce/nodes/ve.ce.MWTransclusionNode.js
@@ -24,7 +24,7 @@
 
        // Mixin constructors
        ve.ce.FocusableNode.call( this );
-       OO.ui.IconElement.call( this, $.extend( {}, config, { $icon: 
this.$element } ) );
+       OO.ui.IconElement.call( this, config );
        ve.ce.GeneratedContentNode.call( this );
 };
 
@@ -126,6 +126,8 @@
  * @see ve.ce.GeneratedContentNode#render
  */
 ve.ce.MWTransclusionNode.prototype.render = function ( generatedContents ) {
+       // Detach the icon
+       this.$icon.detach();
        // Call parent mixin
        ve.ce.GeneratedContentNode.prototype.render.call( this, 
generatedContents );
 
@@ -140,10 +142,15 @@
                        this.$element.height() < 8
                )
        ) {
-               this.setIconElement( this.$element );
-               // The template is empty or hidden
+               // We have to reset the icon when it is reappended, because
+               // setIcon also affects the classes attached to this.$element
                this.setIcon( 'template' );
+               // Reattach icon
+               this.$element.prepend( this.$icon );
        } else {
+               // We have to clear the icon because if the icon's symbolic name
+               // has not changed since the last time we rendered, 
this.setIcon()
+               // above will internally short circuit.
                this.setIcon( null );
        }
 };
diff --git a/modules/ve-mw/ce/styles/nodes/ve.ce.MWTransclusionNode.css 
b/modules/ve-mw/ce/styles/nodes/ve.ce.MWTransclusionNode.css
index b9fe6c8..b8d8600 100644
--- a/modules/ve-mw/ce/styles/nodes/ve.ce.MWTransclusionNode.css
+++ b/modules/ve-mw/ce/styles/nodes/ve.ce.MWTransclusionNode.css
@@ -10,8 +10,13 @@
        vertical-align: middle;
        padding: 0.2em;
        margin: -0.25em 0.15em 0 0.15em;
-       width: 1em;
-       height: 1em;
+}
+
+.ve-ce-mwTransclusionNode.oo-ui-iconElement .oo-ui-iconElement-icon {
+       display: inline-block;
+       vertical-align: middle;
+       width: 1.25em;
+       height: 1.25em;
        background-repeat: no-repeat;
        background-position: center center;
        background-size: 24px 24px;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I5bcbe531cb1db1a4ac25ed4a2f462dde08513b7b
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Mooeypoo <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: Trevor Parscal <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to