Title: [295500] trunk/Source/WebInspectorUI/UserInterface/Views/InlineSwatch.js
Revision
295500
Author
rcali...@apple.com
Date
2022-06-13 13:19:05 -0700 (Mon, 13 Jun 2022)

Log Message

REGRESSION (r251194): Web Inspector: Uncaught exception when inspecting color referenced by CSS variable
https://bugs.webkit.org/show_bug.cgi?id=241558

Reviewed by Devin Rousso.

The patch for https://bugs.webkit.org/show_bug.cgi?id=241055 introduced an option
to prevent changing color formats when interacting with an inline color swatch.

The value of the `preventChangingColorFormats` option kept as an instance property of `WI.InlineSwatch`.
This is then referenced in the callback passed to `createCodeMirrorColorTextMarkers()`. The
callback doesn't share the same scope, so an exception is raied when calling `this._preventChangingColorFormats`.

This patch ensures the value of the instance property is captured in the scope of the callback passed.

* Source/WebInspectorUI/UserInterface/Views/InlineSwatch.js:
(WI.InlineSwatch.prototype._swatchElementClicked.switch.case.WI.InlineSwatch.Type.Variable.optionsForType):
(WI.InlineSwatch.prototype._swatchElementClicked):

Canonical link: https://commits.webkit.org/251505@main

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/InlineSwatch.js (295499 => 295500)


--- trunk/Source/WebInspectorUI/UserInterface/Views/InlineSwatch.js	2022-06-13 20:07:44 UTC (rev 295499)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/InlineSwatch.js	2022-06-13 20:19:05 UTC (rev 295500)
@@ -382,11 +382,13 @@
             codeMirror.setValue(value);
 
             const range = null;
+            let preventChangingColorFormats = this._preventChangingColorFormats;
+
             function optionsForType(type) {
                 return {
                     allowedTokens: /\btag\b/,
                     callback(marker, valueObject, valueString) {
-                        let swatch = new WI.InlineSwatch(type, valueObject, {readOnly: true, preventChangingColorFormats: this._preventChangingColorFormats});
+                        let swatch = new WI.InlineSwatch(type, valueObject, {readOnly: true, preventChangingColorFormats});
                         codeMirror.setUniqueBookmark({line: 0, ch: 0}, swatch.element);
                     }
                 };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to