Skip to content

Commit

Permalink
Merge pull request #322 from hzbhzb/fix/update_style_error
Browse files Browse the repository at this point in the history
fix: Style didn't take effect and offsetLeftToScrollContainer value is calculated incorrectly
  • Loading branch information
andycall committed Apr 19, 2023
2 parents 557e5f7 + 497adb4 commit 86a82f8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 21 additions & 1 deletion integration_tests/specs/css/css-variables/css-variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe('CSS Variables', () => {
}
`)
);

document.body.appendChild(
<div class='container'>
<h2>The text should be green.</h2>
Expand Down Expand Up @@ -274,6 +274,26 @@ describe('CSS Variables', () => {
});
});

it('the text color should be green', async (done) => {

const div = document.createElement('div');
div.appendChild(document.createTextNode('Green Text'));
div.className = "textcolor";
document.body.appendChild(div);
const style = document.createElement('style');
document.head.appendChild(style);
style.appendChild(document.createTextNode(`
.textcolor {
color: green;
}
`));

requestAnimationFrame(async () => {
await snapshot();
done();
});
});

function createStyle(text) {
const style = document.createElement('style');
style.appendChild(document.createTextNode(text));
Expand Down
2 changes: 1 addition & 1 deletion webf/lib/src/css/positioned.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class CSSPositionedLayout {
double childWidth = child.boxSize!.width;
double scrollContainerWidth = scrollContainer.boxSize!.width;
// Dynamic offset to scroll container
double offsetLeftToScrollContainer = childToScrollContainerOffset.dx - scrollContainer.scrollLeft;
double offsetLeftToScrollContainer = childToScrollContainerOffset.dx;
double offsetRightToScrollContainer = scrollContainerWidth - childWidth - offsetLeftToScrollContainer;
RenderStyle childRenderStyle = child.renderStyle;
RenderStyle? scrollContainerRenderStyle = scrollContainer.renderStyle;
Expand Down
1 change: 1 addition & 0 deletions webf/lib/src/html/head.dart
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ class StyleElement extends Element {
}
if (_styleSheet != null) {
ownerDocument.styleNodeManager.appendPendingStyleSheet(_styleSheet!);
ownerDocument.updateStyleIfNeeded();
}
}
}
Expand Down

0 comments on commit 86a82f8

Please sign in to comment.