Skip to content

Commit

Permalink
requestOverride can now fallback to calling clearOverride
Browse files Browse the repository at this point in the history
Fixes #31
  • Loading branch information
lukewarlow committed Oct 3, 2023
1 parent dcc0733 commit 5ad92d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -98,7 +98,7 @@ interface PreferenceObject {
readonly override: string | null;
readonly validValues: string[];

requestOverride(value: string): Promise<void>;
requestOverride(value: string | null): Promise<void>;
clearOverride(): void;
}

Expand Down
10 changes: 6 additions & 4 deletions index.bs
Expand Up @@ -191,7 +191,7 @@ interface PreferenceObject {
readonly attribute FrozenArray<DOMString> validValues;

undefined clearOverride();
Promise<undefined> requestOverride(DOMString value);
Promise<undefined> requestOverride(DOMString? value);
};
</script>

Expand Down Expand Up @@ -230,15 +230,18 @@ interface PreferenceObject {
1. Let |allowed| be `false`.
1. Set |allowed| to the result of executing a UA defined algorithm for deciding whether the request is allowed.
1. If |allowed| is `false`, return [=a promise rejected with=] a "{{NotAllowedError}}" {{DOMException}}.
1. Let |value| be the method's argument.
1. Let |result| be [=a new promise=].
1. If |value| is `null` or an empty [=string=]:
1. Run {{clearOverride}}.
1. [=Resolve=] and return |result|.
1. Let |preference| be the preference object's name.
1. Let |validValues| be null.
1. If |preference| is "{{colorScheme}}", set |validValues| to the result of [=get valid values for colorScheme=].
1. If |preference| is "{{contrast}}", set |validValues| to the result of [=get valid values for contrast=].
1. If |preference| is "{{reducedMotion}}", set |validValues| to the result of [=get valid values for reducedMotion=].
1. If |preference| is "{{reducedTransparency}}", set |validValues| to the result of [=get valid values for reducedTransparency=].
1. If |preference| is "{{reducedData}}", set |validValues| to the result of [=get valid values for reducedData=].
1. Let |value| be the method's argument.
1. Let |result| be [=a new promise=].
1. If |value| is not in |validValues|:
1. [=Reject=] |result| with a "{{TypeError}}" {{DOMException}}.
1. Return |result|.
Expand All @@ -253,7 +256,6 @@ Issue: This algorithm needs more detail on what exactly setting the preference o

Issue: Is TypeError correct here?


### {{clearOverride}} method ### {#clear-override-method}

<div algorithm='clear preference override'>
Expand Down

0 comments on commit 5ad92d7

Please sign in to comment.