Explorar o código

Workaround the lack of lookbehind RegExp assertion in Firefox,

as suggested at https://github.com/ckeditor/ckeditor5/pull/6801#discussion_r424426269.
Tomek Wytrębowicz %!s(int64=5) %!d(string=hai) anos
pai
achega
d3513944db
Modificáronse 1 ficheiros con 5 adicións e 2 borrados
  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.
 // @param {String} colorString The value to be normalized.
 // @returns {String}
 // @returns {String}
 function normalizeColor( colorString ) {
 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.
 	// 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, ' ' );
 }
 }