Skip to content

Commit

Permalink
fix: getAllComputedStyles in domlike backend impl
Browse files Browse the repository at this point in the history
  • Loading branch information
LastLeaf committed Jul 23, 2024
1 parent 10b70c0 commit 52c3319
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 5 additions & 5 deletions glass-easel/src/backend/current_window_backend_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -522,17 +522,17 @@ export class CurrentWindowBackendContext implements Context {
cb(node?.__wxElement ?? null)
}

getAllComputedStyle(
getAllComputedStyles(
target: Element,
cb: (computedStyle: { name: string; value: string }[]) => void,
cb: (computedStyle: { properties: { name: string; value: string }[] }) => void,
): void {
const style = window.getComputedStyle(target as unknown as HTMLElement)
const res: { name: string; value: string }[] = []
const properties: { name: string; value: string }[] = []
for (let i = 0; i < style.length; i += 1) {
const name = style[i]!
res.push({ name, value: style.getPropertyValue(name) })
properties.push({ name, value: style.getPropertyValue(name) })
}
cb(res)
cb({ properties })
}

getScrollOffset(target: Element, cb: (res: ScrollOffset) => void): void {
Expand Down
8 changes: 8 additions & 0 deletions glass-easel/src/backend/suggested_backend_protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ interface GetWrapper<T> {
export type Element<E> = {
getAllComputedStyles(cb: (res: GetAllComputedStylesResponses) => void): void
getBoundingClientRect(cb: (res: BoundingClientRect) => void): void
getBoxModel(
cb: (res: {
margin: BoundingClientRect
border: BoundingClientRect
padding: BoundingClientRect
content: BoundingClientRect
}) => void,
): void
createIntersectionObserver(
relativeElement: E | null,
relativeElementMargin: string,
Expand Down

0 comments on commit 52c3319

Please sign in to comment.