8
0
Просмотр исходного кода

Workaround the lack of lookbehind RegExp assertion in Firefox,

as suggested at https://github.com/ckeditor/ckeditor5/pull/6801#discussion_r424426269.
Tomek Wytrębowicz 5 лет назад
Родитель
Сommit
d3513944db
1 измененных файлов с 5 добавлено и 2 удалено
  1. 5 2
      packages/ckeditor5-table/src/ui/colorinputview.js

+ 5 - 2
packages/ckeditor5-table/src/ui/colorinputview.js

@@ -315,7 +315,10 @@ export default class ColorInputView extends View {
 // @param {String} colorString The value to be normalized.
 // @returns {String}
 function normalizeColor( colorString ) {
-	// Remove any whitespace at the beginning, after `(`, or `,`, at the end, before `)`, `,`, or another whitespace.
+	// Remove any whitespace right after `(` or `,`.
+	// Remove any whitespace at the beginning or right before the end, `)`, `,`, or another whitespace.
 	// Then, replace `,` or whitespace with single space.
-	return colorString.replace( /(?<=^|\(|,)\s*|\s*(?=$|\)|\s|,)|/g, '' ).replace( /,|\s/g, ' ' );
+	return colorString.replace( /([(,])\s+/g, '$1' )
+		.replace( /^\s+|\s+(?=[),\s]|$)/g, '' )
+		.replace( /,|\s/g, ' ' );
 }