Skip to content

Order flag properties - #30469

Merged
caugner merged 2 commits into
mdn:mainfrom
Elchi3:flag-property-order
Sep 11, 2026
Merged

caugner merged 2 commits into
mdn:mainfrom
Elchi3:flag-property-order

Conversation

@Elchi3

@Elchi3 Elchi3 commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

Summary

To update BCD programmatically, for example from the OWD Collector project, diffs are cleaner when ordering is guaranteed. We already have this for several structures. I'm currently working on adding support for collecting flag data to the Collector project and I would benefit from a stable property order in the flag object.

This PR updates stringify-and-order-properties.js and enforces sorting:

  1. type
  2. name
  3. value_to_set

And then I ran npm run fix, to fix the data.

Test results and supporting details

I added a test to stringify-and-order-properties.test.js

Related issues

None, I think.

@Elchi3
Elchi3 requested review from a team as code owners September 10, 2026 10:53
@Elchi3
Elchi3 requested a review from caugner September 10, 2026 10:53
@github-actions github-actions Bot added infra Issue concerning project infrastructure, such as npm, GitHub Actions, or releases. data:http Compatibility data for HTTP features. https://developer.mozilla.org/docs/Web/HTTP data:webext Compatibility data for browser extensions. https://developer.mozilla.org/Add-ons/WebExtensions data:api Compatibility data for Web API features. https://developer.mozilla.org/docs/Web/API data:css Compatibility data for CSS features. https://developer.mozilla.org/docs/Web/CSS data:js Compatibility data for JavaScript features. https://developer.mozilla.org/docs/Web/JavaScript data:html Compatibility data for HTML features. https://developer.mozilla.org/docs/Web/HTML scripts Issue or pull request concerning scripts in . data:mediatypes Compatibility data for media types. https://developer.mozilla.org/docs/Web/Media size:xl Pull request changing more than 1,000 lines of code. labels Sep 10, 2026
@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Tip: Review these changes grouped by change (recommended for most PRs), or grouped by feature (for large PRs).

@ddbeck

ddbeck commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

A little bikeshedding for you, @Elchi3. Do you know how frequent one sort order is versus another?

It feels like type comes first a lot and I kinda like it appearing first, since it's the "outer" context where you set the flag (so it's a bit like describing a menu, as in File → Print…).

But I suppose the "right" thing to do is to use the most frequent existing sort order (or to put this another way, to modify the fewest instances), to limit conflicts to open PRs.

@github-actions github-actions Bot added size:l Pull request changing 101-1,000 lines of code. and removed data:http Compatibility data for HTTP features. https://developer.mozilla.org/docs/Web/HTTP data:webext Compatibility data for browser extensions. https://developer.mozilla.org/Add-ons/WebExtensions data:js Compatibility data for JavaScript features. https://developer.mozilla.org/docs/Web/JavaScript data:mediatypes Compatibility data for media types. https://developer.mozilla.org/docs/Web/Media size:xl Pull request changing more than 1,000 lines of code. labels Sep 10, 2026
@Elchi3
Elchi3 force-pushed the flag-property-order branch from 1943015 to 4319920 Compare September 10, 2026 11:43
@caugner

caugner commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

It feels like type comes first a lot and I kinda like it appearing first, since it's the "outer" context where you set the flag (so it's a bit like describing a menu, as in File → Print…).

I would argue name is more important so it should come first, just like we put "description" first. For me, the type is an historical artifact that mostly isn't necessary, because runtime flags can usually be distinguished from prefs by leading -.

@Elchi3

Elchi3 commented Sep 10, 2026

Copy link
Copy Markdown
Member Author

I have no strong feelings. As you can see with my second commit, the diff is smaller with type first.

@caugner

caugner commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

But I suppose the "right" thing to do is to use the most frequent existing sort order (or to put this another way, to modify the fewest instances), to limit conflicts to open PRs.

I don't think we should care about minimizing changes, or limiting conflicts to open PRs. There are only 6 PRs that change flag data:

Resolving the merge conflicts should be straight-forward in all cases.

@caugner

caugner commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

How would we feel about allowing …

{
  "flags": ["Contact Picker API"],
  // …
  "flags": ["-unstable-webgpu"],
}

… and replacing those as build time by:

{
  "flags": [{"name": "Contact Picker API", "type": "preference"}],
  // …
  "flags": [{"name": "-unstable-webgpu", "type": "runtime_flag"}],
}

If we're okay with that, we can make that change first, and then I don't have strong opinions about the order of the expanded form (where a specific pref value needs to be set).

@Elchi3

Elchi3 commented Sep 10, 2026

Copy link
Copy Markdown
Member Author

because runtime flags can usually be distinguished from prefs by leading -.

I don't think that's true. See https://peter.sh/experiments/chromium-command-line-switches/

@ddbeck

ddbeck commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

How would we feel about allowing … [a shorthand notation for flags]

No, I'm not a fan of that. Flags are a fairly uncommon kind of data and I don't think we should increase magic (and complexity) on things that are the much less likely to get scrutiny than more common patterns in our data.

Anyway, I still like the smaller diff with type first. In the absence of a clear reason to choose one sort over another, aligning to the status quo like a good option. And if someone still wants a different sort, then they can advocate for it affirmatively in a follow up PR.

(Also, if we're nominating things to invest new linting effort into, I'd like to return to the idea of allowlisting flag names in the browser .json files, so other consumers can benefit too.)

@caugner

caugner commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

I don't think that's true. See peter.sh/experiments/chromium-command-line-switches

I don't see any preference starting with - or any runtime flag (aka switch) not starting witih - in that list. Here is an inventory of flags currently in BCD:

preference
  chrome
    #enable-experimental-web-platform-features: 159
    #enable-jxl-image-format: 1
    #extension-apis: 1
    #local-network-access-check: 1
    #web-app-install-element: 16
    #web-app-installation-api: 3
    #web-machine-learning-neural-network: 125
    WebAuth: 1
    enable-experimental-web-platform-features: 27
  edge
    #edge-llm-prompt-api-for-phi-mini: 13
    enable-experimental-web-platform-features: 31
  firefox
    browser.dom.window.dump.enabled: 1
    dom.compression_streams.zstd.enabled: 2
    dom.css_pseudo_element.enabled: 3
    dom.enable_container_timing: 14
    dom.headingoffset.enabled: 4
    dom.imagecapture.enabled: 4
    dom.indexedDB.experimental: 3
    dom.multiple_import_maps.enabled: 1
    dom.payments.request.enabled: 33
    dom.payments.request.supportedRegions: 24
    dom.permissions.revoke.enable: 1
    dom.screenBrightnessProperty.enabled: 1
    dom.screenEnabledProperty.enabled: 1
    dom.security.featurePolicy.webidl.enabled: 7
    dom.select.customizable_select.enabled: 3
    dom.serviceWorkers.navigationPreload.enabled: 1
    dom.shadowdom.referenceTarget.enabled: 4
    dom.vr*: 7
    dom.vr.enabled: 69
    dom.webnotifications.requireinteraction.enabled: 1
    dom.webshare.enabled: 4
    javascript.options.experimental.regexp_buffer_boundaries: 1
    javascript.options.experimental.wasm_esm_integration: 1
    layout.css.appearance-base.enabled: 3
    layout.css.custom-media.enabled: 2
    layout.css.element-content-none.enabled: 1
    layout.css.fit-content-function.enabled: 12
    layout.css.getBoxQuads.enabled: 3
    layout.css.heading-selector.enabled: 2
    layout.css.inverted-colors.enabled: 1
    layout.css.line-clamp.enabled: 2
    layout.css.moz-submit-invalid.enabled: 1
    layout.css.prefers-reduced-transparency.enabled: 1
    layout.css.scroll-driven-animations.enabled: 2
    layout.css.text-box.enabled: 5
    media.mediasource.experimental.enabled: 2
    media.track.enabled: 27
    media.webspeech.recognition.enable: 37
    network.cookie.sameSite.laxByDefault: 1
    network.cookie.sameSite.schemeful: 1
    network.cors_preflight.authorization_covered_by_wildcard: 1
    network.http.dictionaries.enable: 8
    network.http.idempotencyKey.enabled: 1
    security.integrity_policy.stylesheet.enabled: 2
  safari
    <select> showPicker() method: 1
    CSS font-variant-emoji property: 1
    Canvas Filters: 1
    Cookie Store API CookieStoreManager: 4
    LinkPrefetch: 1
    Shape Detection API: 4
    SpeculationRules prefetch: 15
    referenceTarget: 4
    referenceTarget support for aria-owns: 4
    requestIdleCallback: 5
  safari_ios
    Contact Picker API: 4
runtime_flag
  chrome
    --enable-blink-features=ExperimentalProductivityFeatures: 2
  deno
    --location [url]: 15
    --unsafe-proto: 1
    --unstable-net: 44
    --unstable-node-globals: 1
    --unstable-unsafe-proto: 1
    --unstable-webgpu: 203
  nodejs
    --inspect: 4

All runtime flags start with -, and no preference starts with -.

@caugner

caugner commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

I'd like to return to the idea of allowlisting flag names in the browser .json files, so other consumers can benefit too.

I don't think BCD should publish list of browser flags/runtime flags, but I could imagine creating a browser-flag-inventory package (like mdn-content-inventory) outside of the MDN org.

@Elchi3

Elchi3 commented Sep 11, 2026

Copy link
Copy Markdown
Member Author

OK, it seems like more discussion is needed about flags. I'm glad there is an appetite to do more work on them.

For this PR, can we come to a decision, though? I scoped this PR just to get stable flag objects...

@caugner

caugner commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

If we're open to allowing short-hands in the future (which simplifies manual and automated authoring, and increases readability by reducing noise), I don't have strong opinions about the ordering. Otherwise, the most important property (the name) should come first, which coincides with the alphabetical ordering (name, type, value_to_set).

The status quo is not necessarily intentional.

And if someone still wants a different sort, then they can advocate for it affirmatively in a follow up PR.

Surely once this PR has landed it will be almost impossible to convince you to change the ordering, if you're reluctant to make changes that introduce git history noise or that may cause merge conflicts.

Edit: I retract the above characterization. What I was trying, poorly, to express was a concern about the consequences of postponing the decision: after normalizing the repository to type-first, changing it later would produce the large diff/history noise that is currently an argument for retaining type-first. Doesn't that make postponing this decision somewhat self-reinforcing?

@ddbeck

ddbeck commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Surely once this PR has landed it will be almost impossible to convince you

@caugner What are you on about? This is out of line. A false accusation of intransigence is unprofessional and unwarranted.

I said that I liked the type-first order. I never said I was firmly committed to it. I characterized my own position as "bikeshedding." I called the small-diff approach the procedurally "right" choice (in sneer quotes!), informed by my experience with the migrations process of old, which is explicitly diff conscious.

I am not certain that type-first is the best option. I am open to other considerations. For example, we have not sought other contributors' input; I suspect Hamish and Chris have higher-than-average experience authoring this kind of data and might have valuable contributions to such a discussion.

In the absence of a quick and easy consensus, I earnestly wished to get something merged (for Florian to achieve the stability goal) and to let the the many threads here (sort order, build-time transformations, flag allowlists, etc.) to find their way to their own PRs and issues.

To close, I regret expressing my opinion here and bringing up extraneous issues. I am going to mark this PR approved, but otherwise withdraw from discussion here. You may sort it any which way you like.

@caugner

caugner commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

What are you on about? This is out of line. A false accusation of intransigence is unprofessional and unwarranted.

Apologies. I sincerely regret my wording. I misinterpreted your reasoning and the intention behind your suggestion, and I should not have made that assumption about your position.

Let's land this order, even if it's not the one I consider preferable and Florian initially suggested. Then let me make the case for the shorthand in one of our next meetings.

@caugner
caugner merged commit 97d7763 into mdn:main Sep 11, 2026
11 checks passed
@Elchi3
Elchi3 deleted the flag-property-order branch September 11, 2026 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data:api Compatibility data for Web API features. https://developer.mozilla.org/docs/Web/API data:css Compatibility data for CSS features. https://developer.mozilla.org/docs/Web/CSS data:html Compatibility data for HTML features. https://developer.mozilla.org/docs/Web/HTML infra Issue concerning project infrastructure, such as npm, GitHub Actions, or releases. scripts Issue or pull request concerning scripts in . size:l Pull request changing 101-1,000 lines of code.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants