Skip to content

Commit

Permalink
Add value attribute ot PreferenceObject
Browse files Browse the repository at this point in the history
This provides a mechanism to get the computed preference value.

Fixes #7
  • Loading branch information
lukewarlow committed Jan 15, 2024
1 parent 78e3e24 commit 4400ef2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -96,6 +96,7 @@ interface PreferenceManager {
interface PreferenceObject {
// null means the preference is not overridden
readonly override: string | null;
readonly value: string;
readonly validValues: string[];

requestOverride(value: string | null): Promise<void>;
Expand Down
13 changes: 13 additions & 0 deletions index.bs
Expand Up @@ -184,6 +184,7 @@ If an override is set for this preference:
[Exposed=Window, SecureContext]
interface PreferenceObject {
readonly attribute DOMString? override;
readonly attribute DOMString value;
readonly attribute FrozenArray<DOMString> validValues;

undefined clearOverride();
Expand All @@ -202,6 +203,18 @@ interface PreferenceObject {
1. Return |override|.
</div>

### {{value}} attribute ### {#value-attribute}

<div algorithm='get preference value'>
The <dfn attribute for=PreferenceObject>value</dfn> attribute, when accessed, must run these steps:

1. Let |preference| be the preference object's name.
1. Let |value| be null.
1. If an override for |preference| exists, set |value| to the value of that override.
1. If |value| is null, set |value| to the UA value of the preference.
1. Return |value|.
</div>

### {{validValues}} attribute ### {#validValues-attribute}

<div algorithm>
Expand Down

0 comments on commit 4400ef2

Please sign in to comment.