Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Style didn't take effect and offsetLeftToScrollContainer value is calculated incorrectly #322

Merged
merged 3 commits into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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