| Summary: | Web Inspector: Can't edit certain style rules on twitter.com (created by React Native StyleSheet) | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Nikita Vasilyev <nvasilyev> | ||||||||
| Component: | Web Inspector | Assignee: | Nikita Vasilyev <nvasilyev> | ||||||||
| Status: | ASSIGNED --- | ||||||||||
| Severity: | Normal | CC: | hi, inspector-bugzilla-changes, webkit-bug-importer | ||||||||
| Priority: | P2 | Keywords: | InRadar | ||||||||
| Version: | WebKit Nightly Build | ||||||||||
| Hardware: | All | ||||||||||
| OS: | All | ||||||||||
| URL: | https://reactnative.dev/docs/stylesheet | ||||||||||
| Attachments: |
|
||||||||||
|
Description
Nikita Vasilyev
2020-10-21 10:09:01 PDT
When clicking on "margin-top": [Error] TypeError: null is not an object (evaluating 'this._styleSheetTextRange.collapseToEnd') _rangeAfterPropertyAtIndex (CSSStyleDeclaration.js:547) newBlankProperty (CSSStyleDeclaration.js:412) addBlankProperty (SpreadsheetCSSStyleDeclarationEditor.js:326) _handleClick (SpreadsheetCSSStyleDeclarationSection.js:608) _handleClick In Twitter HTML, I see this:
```
<style>
html, body {
height: 100%;
}
body {
-ms-overflow-style: scrollbar;
overflow-y: scroll;
overscroll-behavior-y: none;
}
</style>
<style id="react-native-stylesheet">
[stylesheet-group="0"] {
}
html {
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
body {
margin: 0;
}
```
Everything in the 1st <style> element is editable just fine. Everything in the 2nd is not.
This CSSStyleDeclaration instance doesn't have `this._styleSheetTextRange` yet it has this.ownerStyleSheet. That's very odd.
None of these work: https://reactnative.dev/docs/stylesheet This must have impacted many websites. Investigating how React Native constructs stylesheets. My guess would be that it uses CSSOM. *** Bug 218297 has been marked as a duplicate of this bug. *** Created attachment 413201 [details]
[HTML] Reduction
Created attachment 413202 [details]
[HTML] Reduction
Created attachment 413205 [details]
WIP
This diff has front-end changes necessary to make CSS properties editable. However, I discovered that the backend part is broken, too :(
```
<style id="style_element"></style>
<script>
style_element.sheet.insertRule("body {color: green}", 0);
</script>
```
With this WIP applied, inspect <body> and change the color from "green" to "blue". The following error will happen:
[Error] Error saving style: – "NotFoundError"
styleTextDidChange (CSSStyleDeclaration.js:238)
The error is coming from the backend. Specifically, `target.CSSAgent.setStyleText(style.id, text, didSetStyleText)` can't seem to be able to find and update dynamically created styles.
|