Skip to content

Commit

Permalink
Add default value to context parameter (#1531)
Browse files Browse the repository at this point in the history
  • Loading branch information
rcj-siteimprove authored Dec 12, 2023
1 parent 874f0e6 commit 4985c4e
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions packages/alfa-style/src/node/predicate/is-visible.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Cache } from "@siteimprove/alfa-cache";
import { Numeric } from "@siteimprove/alfa-css";
import { Device } from "@siteimprove/alfa-device";
import { Element, Text, Node } from "@siteimprove/alfa-dom";
import { Option } from "@siteimprove/alfa-option";
import { Element, Node, Text } from "@siteimprove/alfa-dom";
import { Predicate } from "@siteimprove/alfa-predicate";
import { Refinement } from "@siteimprove/alfa-refinement";
import { Context } from "@siteimprove/alfa-selector";
Expand Down Expand Up @@ -30,16 +29,16 @@ export function isVisible(device: Device, context?: Context): Predicate<Node> {
return not(isInvisible(device, context));
}

const cache = Cache.empty<
Device,
Cache<Option<Context>, Cache<Node, boolean>>
>();
const cache = Cache.empty<Device, Cache<Context, Cache<Node, boolean>>>();

function isInvisible(device: Device, context?: Context): Predicate<Node> {
function isInvisible(
device: Device,
context: Context = Context.empty(),
): Predicate<Node> {
return (node) =>
cache
.get(device, Cache.empty)
.get(Option.from(context), Cache.empty)
.get(context, Cache.empty)
.get(node, () =>
test(
or(
Expand Down

0 comments on commit 4985c4e

Please sign in to comment.