RESOLVED FIXED 218295
Web Inspector: Extra closing parenthesis added after var in styles panel
https://bugs.webkit.org/show_bug.cgi?id=218295
Summary Web Inspector: Extra closing parenthesis added after var in styles panel
Zach Bjornson
Reported 2020-10-28 11:00:56 PDT
Given a rule like: .class { --my-var: calc(var(--other-var) * 1em); } The Styles panel adds an extra closing parenthesis, making it look like: --my-var: calc(var(--other-var)) * 1em); Tested in Safari 13.1.2.
Attachments
WIP (2.76 KB, patch)
2020-10-28 17:58 PDT, Nikita Vasilyev
nvasilyev: commit-queue-
Patch (2.75 KB, patch)
2020-10-29 15:38 PDT, Nikita Vasilyev
no flags
Nikita Vasilyev
Comment 1 2020-10-28 11:02:21 PDT
Thank you for reporting, I'll look into this.
Radar WebKit Bug Importer
Comment 2 2020-10-28 11:02:58 PDT
Nikita Vasilyev
Comment 3 2020-10-28 16:13:54 PDT
WI.SpreadsheetStyleProperty.prototype._addVariableTokens(tokens) returns an array of tokens with an extra closed parenthesis.
Nikita Vasilyev
Comment 4 2020-10-28 17:58:52 PDT
Created attachment 412596 [details] WIP This fixes the bug. However, this method is pretty error prone and could really benefit from unit tests. I'm planning to move it outside of the Views.
Devin Rousso
Comment 5 2020-10-29 12:02:24 PDT
Comment on attachment 412596 [details] WIP View in context: https://bugs.webkit.org/attachment.cgi?id=412596&action=review > Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js:-826 > - contents.pushAll(rawTokens.slice(variableNameIndex + 1, i)); We also probably should remove the `, i` above too. Using `i` is incorrect because `rawTokens` is not the same length as `tokens` :/ > Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js:-827 > - contents.push(token); I think this was ultimately the issue (i.e. you could leave the `i + 1` as is above).
Nikita Vasilyev
Comment 6 2020-10-29 14:08:23 PDT
Comment on attachment 412596 [details] WIP View in context: https://bugs.webkit.org/attachment.cgi?id=412596&action=review >> Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js:-826 >> - contents.pushAll(rawTokens.slice(variableNameIndex + 1, i)); > > We also probably should remove the `, i` above too. Using `i` is incorrect because `rawTokens` is not the same length as `tokens` :/ You mean on the line 817, right? Yes, it shouldn't be used there. And yes, that's why I'm removing `, i`. >> Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js:-827 >> - contents.push(token); > > I think this was ultimately the issue (i.e. you could leave the `i + 1` as is above). My change on line 793 alone fixes this bug. At the same time, all the changes in this patch but on the line 793 fixes the bug, too :) However, keeping the ")" at the end of rawTokens isn't used for anything, and is a footgun.
Nikita Vasilyev
Comment 7 2020-10-29 15:37:39 PDT
Comment on attachment 412596 [details] WIP View in context: https://bugs.webkit.org/attachment.cgi?id=412596&action=review >>> Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js:-827 >>> - contents.push(token); >> >> I think this was ultimately the issue (i.e. you could leave the `i + 1` as is above). > > My change on line 793 alone fixes this bug. At the same time, all the changes in this patch but on the line 793 fixes the bug, too :) > However, keeping the ")" at the end of rawTokens isn't used for anything, and is a footgun. Actually, I see rawTokens is being used in fallbackTokens, which is passed to the rest of _add*Tokens function. I'll take your suggestion and leave it as-is. "At the same time, all the changes in this patch but on the line 793 fixes the bug, too :)" — this statement was incorrect :/
Nikita Vasilyev
Comment 8 2020-10-29 15:38:53 PDT
Created attachment 412694 [details] Patch Now it's a really tiny patch ☺️
Devin Rousso
Comment 9 2020-10-30 10:15:43 PDT
Comment on attachment 412694 [details] Patch r=me
EWS
Comment 10 2020-10-30 11:06:33 PDT
Committed r269201: <https://trac.webkit.org/changeset/269201> All reviewed patches have been landed. Closing bug and clearing flags on attachment 412694 [details].
Note You need to log in before you can comment on or make changes to this bug.