From dd6d225ed7b8d2023ccf40819872a236ccbdebfa Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Wed, 27 Nov 2013 22:54:21 +0000 Subject: [PATCH] Don't strip HTML attributes from inspected links When you inspect a link, then close the inspector immediately, nothing should change. However, AnnotationInspector was comparing the generated annotation and the existing annotation by hash, and so would consider an annotation with htmlAttributes different from one without. This meant that inspecting a Parsoid-generated link and then closing the inspector would cause a transaction to be processed that removes the htmlAttributes from the annotation. I believe a similar issue also existed for annotations with attributes like origTitle and hrefPrefix, although I didn't reproduce this. The fix is to have AnnotationInspector compare annotations by the hash of their comparableObjects, rather than their hashObjects. Change-Id: I848ffc2b7e7b2c67754a0ece3af105ffafa837ec --- modules/ve/ui/inspectors/ve.ui.AnnotationInspector.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ve/ui/inspectors/ve.ui.AnnotationInspector.js b/modules/ve/ui/inspectors/ve.ui.AnnotationInspector.js index 773e01fad3..29e34f90ec 100644 --- a/modules/ve/ui/inspectors/ve.ui.AnnotationInspector.js +++ b/modules/ve/ui/inspectors/ve.ui.AnnotationInspector.js @@ -133,7 +133,7 @@ ve.ui.AnnotationInspector.prototype.setup = function ( data ) { // Note we don't set the 'all' flag here - any non-annotated content will be annotated on close this.initialAnnotation = this.getMatchingAnnotations( fragment ).get( 0 ); this.initialAnnotationHash = this.initialAnnotation ? - OO.getHash( this.initialAnnotation ) : null; + OO.getHash( this.initialAnnotation.getComparableObject() ) : null; }; /** @@ -161,7 +161,7 @@ ve.ui.AnnotationInspector.prototype.teardown = function ( data ) { if ( this.initialSelection.isCollapsed() ) { insert = true; } - if ( OO.getHash( annotation ) !== this.initialAnnotationHash ) { + if ( OO.getHash( annotation.getComparableObject() ) !== this.initialAnnotationHash ) { if ( this.isNewAnnotation ) { undo = true; } else {