Skip to content
Permalink
Browse files
REGRESSION (r251194): Web Inspector: Uncaught exception when inspecti…
…ng 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
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@295500 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
rcaliman-apple committed Jun 13, 2022
1 parent 719056f commit 7dec0b8bae5d591a971aa8eb97afe85f99c4dd77
Showing 1 changed file with 3 additions and 1 deletion.
@@ -382,11 +382,13 @@ WI.InlineSwatch = class InlineSwatch extends WI.Object
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);
}
};

0 comments on commit 7dec0b8

Please sign in to comment.