question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support `browser_compatibility` as a front matter key

See original GitHub issue

(and make it available to KS. Actually, make all of front matter available to KS).

Like:

browser_compatibility: css.properties.margin

At the moment compat tables are built something like:

  • authors include the {{ Compat }} macro, passing it a BCD query like “css.properties.margin”
  • the {{ Compat }} macro emits a <div class="bc-data"> with an id set to that query
  • some magic Yari code, when it finds a <div> like that, fetches the BCD query value from the id and uses it to construct a table

Just semantically, I think it would be better to have the BCD query in front matter than as an argument to the {{ Compat }} macro. Then it just represents an extra bit of data to associate with this thing, and the only thing {{ Compat }} is doing is telling Yari where in the page to put the table. And if we ever have machine-readable page types (aka recipes), we don’t need that either, because a common page type would include that location information.

But! BCD can be used for more than just the compat tables. There’s a project to include spec URLs in BCD, and use a KS macro to add the spec tables, based on the BCD query (https://github.com/mdn/content/issues/1146). If the BCD query is in front matter, then compat and spec tables can be driven from that one data item.

Also, BCD indicates when features are “deprecated”: elsewhere we’ve discussed using this to power “This feature is deprecated” warnings in pages. If BCD is in front matter, then this feature can also be driven by the same data item.

Also, we’ve talked in the past about having a sort of “BCD summary” thing at the tops of pages, to flag compat issues. Same thing: if BCD is in the front matter we can use it to drive that, too.


For the first attempt it would be helpful to make this front matter item accessible to KS. Then for now, the platform code that finds the <div class="bc-data"> doesn’t need to change, we could just adjust {{ Compat }} to use the front matter instead of an argument. Ideally I think KS macros should just get access to all front matter values. But eventually we could change things so {{ Compat }} is just not aware of the BCD query at all, in the common case.

We would still need to support a BCD query argument to {{ Compat }}, because some pages contain more than one compat table. But this I think is pretty unusual. So we would make the argument optional (and omit it in 95% of cases).

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:7
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
peterbecommented, Apr 12, 2021

I quite like the hyphenation because it feels more human. browser_compat looks like a programming variable name, whereas browser-compat looks like something a writer would type into a CMS.

My solution takes quite a lax stance. All and anything that’s in the front-matter is available on the env object inside the .ejs code. So you can call it whatever you like in a sense, but you just need to align you edits to the front-matter with the relevant .ejs file that uses it.

1reaction
wbambergcommented, Mar 17, 2021

If we do that, nothing would (need to) change elsewhere. E.g. the way Yari converts the <div class="bc-data" id="bcd:css.properties.margin"> would be unaffected.

Yes, exactly!

I guess we can do a big search-and-replace one-off (or in batches) where we carefully fix index.html pages more or less one at a time.

Biggest question; should it be bcd_query: instead? Easier to not misspel and more accurate as to what it is.

I don’t feel strongly here, but would vote for browser_compatibility: I agree it’s harder to write but it is easier to read, and reading happens more often than writing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Compatibility tables and the browser compatibility data ...
The compatibility data query should be specified in the page front-matter in the browser-compat key. For example, AbortController would be ...
Read more >
Intro to Browser Compatibility - DEV Community ‍ ‍
Browser compatibility refers to the fact that not all CSS properties are supported, or not supported in the same way, across all browsers....
Read more >
Browser compatibility - Shiar's cheat sheets
feature feature feature And. Chrome iOS Edge Safari SS FF feature feature feature 101 99 13 101 14 16 100 feature feature feature And. Chrome...
Read more >
7 Common Cross Browser Compatibility Issues to Avoid
Safari and Chrome (-webkit); Internet Explorer (-ms); Mozilla Firefox (-moz); Opera (-o). 4. DOCTYPE Error. This usually involves some kind ...
Read more >
10 ways to avoid cross browser compatibility issues
These issues are now easier to solve. A common solution is the use of floats which is supported by most browsers. But, a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found