Catrope has uploaded a new change for review.
https://gerrit.wikimedia.org/r/190628
Change subject: ve.dm.ElementLinearData: Remove unused rules.removeStyles
feature
......................................................................
ve.dm.ElementLinearData: Remove unused rules.removeStyles feature
This seems to have been introduced for copy-paste at some point,
but it's now completely unused. Removing this simplifies the
sanitize() method.
Change-Id: I0519600866e6e27aba36071a4947dd72c46eacd1
---
M src/dm/lineardata/ve.dm.ElementLinearData.js
M tests/dm/lineardata/ve.dm.ElementLinearData.test.js
2 files changed, 5 insertions(+), 69 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor
refs/changes/28/190628/1
diff --git a/src/dm/lineardata/ve.dm.ElementLinearData.js
b/src/dm/lineardata/ve.dm.ElementLinearData.js
index 78768b8..231948d 100644
--- a/src/dm/lineardata/ve.dm.ElementLinearData.js
+++ b/src/dm/lineardata/ve.dm.ElementLinearData.js
@@ -868,7 +868,6 @@
* @param {string[]} [rules.blacklist] Blacklist of model types which aren't
allowed
* @param {Object} [rules.conversions] Model type conversions to apply, e.g. {
heading: 'paragraph' }
* @param {boolean} [rules.removeHtmlAttributes] Remove all left over HTML
attributes
- * @param {boolean} [rules.removeStyles] Remove HTML style attributes
* @param {boolean} [plainText=false] Remove all formatting for plain text
import
* @param {boolean} [keepEmptyContentBranches=false] Preserve empty content
branch nodes
*/
@@ -885,19 +884,12 @@
delete allAnnotations.get( i
).element.htmlAttributes;
}
}
- if ( rules.removeStyles ) {
- for ( i = 0, len = allAnnotations.getLength(); i < len;
i++ ) {
- // Remove inline style attributes from
annotations
- ve.dm.Model.static.removeHtmlAttribute(
allAnnotations.get( i ).element, 'style' );
- }
- }
// Create annotation set to remove from blacklist
setToRemove = allAnnotations.filter( function ( annotation ) {
return ve.indexOf( annotation.name, rules.blacklist )
!== -1 || (
- // If HTML attributes or styles are
stripped and you are left with an empty span, remove it
- annotation.name === 'textStyle/span' &&
!annotation.element.htmlAttributes &&
- ( rules.removeHtmlAttributes ||
rules.removeStyles )
+ // If HTML attributes are stripped,
remove spans
+ annotation.name === 'textStyle/span' &&
rules.removeHtmlAttributes
);
} );
}
@@ -956,15 +948,9 @@
this.setAnnotationsAtOffset( i, annotations );
}
}
- if ( this.isOpenElementData( i ) ) {
- if ( rules.removeHtmlAttributes ) {
- // Remove HTML attributes from nodes
- delete this.getData( i ).htmlAttributes;
- }
- if ( rules.removeStyles ) {
- // Remove inline style attributes from nodes
- ve.dm.Model.static.removeHtmlAttribute(
this.getData( i ), 'style' );
- }
+ if ( this.isOpenElementData( i ) && rules.removeHtmlAttributes
) {
+ // Remove HTML attributes from nodes
+ delete this.getData( i ).htmlAttributes;
}
}
};
diff --git a/tests/dm/lineardata/ve.dm.ElementLinearData.test.js
b/tests/dm/lineardata/ve.dm.ElementLinearData.test.js
index 7fdf6b1..aef67c7 100644
--- a/tests/dm/lineardata/ve.dm.ElementLinearData.test.js
+++ b/tests/dm/lineardata/ve.dm.ElementLinearData.test.js
@@ -1379,13 +1379,6 @@
var i, model, data,
count = 0,
bold = new ve.dm.BoldAnnotation( { type: 'textStyle/bold',
attributes: { nodeName: 'b' } } ),
- boldWithClass = new ve.dm.BoldAnnotation( {
- type: 'textStyle/bold',
- attributes: { nodeName: 'b' },
- htmlAttributes: [ {
- values: { class: 'bar' }
- } ]
- } ),
cases = [
{
html: '<p style="text-shadow: 0 0 1px
#000;">F<b style="color:blue;">o</b>o</p>',
@@ -1457,37 +1450,6 @@
msg: 'Empty content nodes are stripped'
},
{
- html: '<p style="font-size: 2em;"><b
style="color:red;">Foo</b></p>',
- data: [
- { type: 'paragraph' },
- ['F', [0]], ['o', [0]], ['o', [0]],
- { type: '/paragraph' },
- { type: 'internalList' },
- { type: '/internalList' }
- ],
- store: [ bold ],
- rules: { removeStyles: true },
- msg: 'Style attribute removed and
htmlAttributes unset'
- },
- {
- html: '<p style="font-size: 2em;"
class="foo"><b style="color:red;" class="bar">Foo</b></p>',
- data: [
- {
- type: 'paragraph',
- htmlAttributes: [ {
- values: { class: 'foo' }
- } ]
- },
- ['F', [0]], ['o', [0]], ['o', [0]],
- { type: '/paragraph' },
- { type: 'internalList' },
- { type: '/internalList' }
- ],
- store: [ boldWithClass ],
- rules: { removeStyles: true },
- msg: 'Style attribute removed and other
attributes preserved'
- },
- {
html: '<p><span style="color:red;"
class="red">Foo</span></p>',
data: [
{ type: 'paragraph' },
@@ -1498,18 +1460,6 @@
],
rules: { removeHtmlAttributes: true },
msg: 'Span empty after HTML attributes removed
is stripped'
- },
- {
- html: '<p><span
style="color:red;">Foo</span></p>',
- data: [
- { type: 'paragraph' },
- 'F', 'o', 'o',
- { type: '/paragraph' },
- { type: 'internalList' },
- { type: '/internalList' }
- ],
- rules: { removeStyles: true },
- msg: 'Span empty after styles removed is
stripped'
}
];
--
To view, visit https://gerrit.wikimedia.org/r/190628
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0519600866e6e27aba36071a4947dd72c46eacd1
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits