Skip to content
Open
Changes from 2 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
35 changes: 24 additions & 11 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -125554,6 +125554,12 @@ interface <dfn interface>Navigator</dfn> {

<div w-nodev>

<div algorithm>
<p>Each object that implements <code>NavigatorLanguage</code> has
an associated <dfn attribute for="NavigatorLanguage">plausible languages array</dfn>,
which is a frozen array of BCP 47 language tags. It is initially empty.</p>
</div>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To do this properly we have to store the object we intend to return on Navigator in an associated concept of sorts. And then each time we run this algorithm we see if any of the values changed, and if not, we return the cached object. And if they have changed, we update the cached object and then return it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... I'm not so sure how to specify the storing of the value 😕 Like where I could keep it. I couldn't really find anything similar in the spec, only the same kind of sentences that the value should be returned until something has changed. Should I write something abstract that there should be some kind of cache for it? Could you maybe give me some pointers/examples?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay. It would be similar to

Each Window has an associated Navigator, ...

Maybe something like:

Each object that implements NavigatorLanguage has an associated plausible languages array, which is a frozen array of BCP 47 language tags. It is initially empty.

And then in the getter algorithm you could do something like:

  1. Let languages be the result of computing plausible languages. (I.e., what the steps do today.)
  2. If languages and this's plausible languages array do not have the same values in the same order, then set this's plausible languages array to languages.
  3. Return this's plausible languages array.

Does that help?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! It does 🙂
I've updated the PR. Please let me know if it looks better now.


<div algorithm>
<p>The <dfn attribute for="NavigatorLanguage"><code
data-x="dom-navigator-language">language</code></dfn> getter steps are:</p>
Expand All @@ -125562,7 +125568,7 @@ interface <dfn interface>Navigator</dfn> {
<li>Let <var>emulatedLanguage</var> be the <span>WebDriver BiDi emulated language</span> for
<span>this</span>'s <span>relevant settings object</span>.</li>

<li>If <var>emulatedLanguage</var> is not null, return <var>emulatedLanguage</var>.</li>
<li>If <var>emulatedLanguage</var> is not null, then return <var>emulatedLanguage</var>.</li>

<li>Return a valid BCP 47 language tag representing either <span>a plausible language</span> or
the user's most preferred language. <ref>BCP47</ref></li>
Expand All @@ -125574,19 +125580,26 @@ interface <dfn interface>Navigator</dfn> {
data-x="dom-navigator-languages">languages</code></dfn> getter steps are:</p>

<ol>
<li>Let <var>emulatedLanguage</var> be the <span>WebDriver BiDi emulated language</span> for
<span>this</span>'s <span>relevant settings object</span>.</li>
<li>Let <var>languages</var> be an empty array.</li>

<li>If <var>emulatedLanguage</var> is not null, return a <span>frozen array</span> containing
<var>emulatedLanguage</var>.</li>
<li>Let <var>emulatedLanguage</var> be the <span>WebDriver BiDi emulated language</span>
for <span>this</span>'s <span>relevant settings object</span>.</li>

<li>Return a <span>frozen array</span> of valid BCP 47 language tags representing either one or
more <span data-x="a plausible language">plausible languages</span>, or the user's preferred
languages, ordered by preference with the most preferred language first. <ref>BCP47</ref></li>
</ol>
<li>If <var>emulatedLanguage</var> is not null, then set <var>languages</var> to
<span>frozen array</span> containing <var>emulatedLanguage</var>.</li>

<li>Otherwise, set <var>languages</var> to <span>frozen array</span> of
valid BCP 47 language tags representing either one or more
<span data-x="a plausible language">plausible languages</span>, or
the user's preferred languages, ordered by preference with
the most preferred language first. <ref>BCP47</ref></li>

<p>The same object must be returned until the user agent needs to return different values, or
values in a different order, or <var>emulatedLanguage</var> is updated.</p>
<li>If <var>languages</var> and <span>this</span>'s <var>plausible languages array</var>
do not have the same values in the same order, then set
<span>this</span>'s <span>plausible languages array</span> to <var>languages</var>.</li>

<li>Return <span>this</span>'s <span>plausible languages array</span>.</li>
</ol>
</div>

<div algorithm>
Expand Down