jenkins-bot has submitted this change and it was merged.
Change subject: Highlight and bind events to $focusable, not $element
......................................................................
Highlight and bind events to $focusable, not $element
Still use this.$element for setting classes and properties.
This reveals a masked bug in nodes which override $focusable/$resizable
and use generatedContent, as GC re-defines this.$element but doesn't update
this.$focusable/this.$resizable.
To fix this add in getters for focusable/resizable to GC node, and use them
to redefine those elements on render.
Change-Id: I2415bbcdf94bbb25773a37e4f3a5048a567bb025
---
M modules/ve/ce/nodes/ve.ce.GeneratedContentNode.js
M modules/ve/ce/ve.ce.FocusableNode.js
2 files changed, 32 insertions(+), 5 deletions(-)
Approvals:
Catrope: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/ve/ce/nodes/ve.ce.GeneratedContentNode.js
b/modules/ve/ce/nodes/ve.ce.GeneratedContentNode.js
index ac536da..c37a987 100644
--- a/modules/ve/ce/nodes/ve.ce.GeneratedContentNode.js
+++ b/modules/ve/ce/nodes/ve.ce.GeneratedContentNode.js
@@ -158,6 +158,15 @@
this.$element.remove();
this.$element = $newElements;
}
+
+ // Update focusable and resizable elements if necessary
+ if ( this.$focusable ) {
+ this.$focusable = this.getFocusableElement();
+ }
+ if ( this.$resizable ) {
+ this.$resizable = this.getResizableElement();
+ }
+
if ( this.live ) {
this.emit( 'setup' );
this.afterRender();
@@ -287,3 +296,21 @@
this.$element.removeClass( 've-ce-generatedContentNode-generating' );
this.generatingPromise = null;
};
+
+/**
+ * Get the focusable element
+ *
+ * @return {jQuery} Focusable element
+ */
+ve.ce.GeneratedContentNode.prototype.getFocusableElement = function () {
+ return this.$element;
+};
+
+/**
+ * Get the resizable element
+ *
+ * @return {jQuery} Resizable element
+ */
+ve.ce.GeneratedContentNode.prototype.getResizableElement = function () {
+ return this.$element;
+};
diff --git a/modules/ve/ce/ve.ce.FocusableNode.js
b/modules/ve/ce/ve.ce.FocusableNode.js
index 4ae1bec..b627f2e 100644
--- a/modules/ve/ce/ve.ce.FocusableNode.js
+++ b/modules/ve/ce/ve.ce.FocusableNode.js
@@ -100,7 +100,7 @@
.prop( 'contentEditable', 'false' );
// Events
- this.$element.on( {
+ this.$focusable.on( {
'mouseenter.ve-ce-focusableNode': ve.bind(
this.onFocusableMouseEnter, this ),
'mousedown.ve-ce-focusableNode touchend.ve-ce-focusableNode':
ve.bind( this.onFocusableMouseDown, this )
} );
@@ -120,7 +120,7 @@
}
// Events
- this.$element.off( '.ve-ce-focusableNode' );
+ this.$focusable.off( '.ve-ce-focusableNode' );
// Highlights
this.clearHighlights();
@@ -308,13 +308,13 @@
this.focused = value;
if ( this.focused ) {
this.emit( 'focus' );
- this.$focusable.addClass( 've-ce-node-focused' );
+ this.$element.addClass( 've-ce-focusableNode-focused' );
this.createHighlights();
this.surface.appendHighlights( this.$highlights,
this.focused );
this.surface.$element.off( '.ve-ce-focusableNode' );
} else {
this.emit( 'blur' );
- this.$focusable.removeClass( 've-ce-node-focused' );
+ this.$element.removeClass(
've-ce-focusableNode-focused' );
this.clearHighlights();
}
}
@@ -402,7 +402,7 @@
rect2.bottom <= rect1.bottom;
}
- this.$element.find( '*' ).addBack().each( function () {
+ this.$focusable.find( '*' ).addBack().each( function () {
var i, j, il, jl, contained, clientRects;
if ( $( this ).hasClass( 've-ce-noHighlight' ) ) {
--
To view, visit https://gerrit.wikimedia.org/r/148966
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I2415bbcdf94bbb25773a37e4f3a5048a567bb025
Gerrit-PatchSet: 2
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits