Archive for May, 2024

Reading List 320

Indian Big Tech draft regulation makes Big Tech bosses cry scandal

I hope you’re sitting down, because Reuters reports that Google, Amazon, Apple lobby group opposes India’s EU-like antitrust proposal:

A U.S. lobby group representing tech giants Google, Amazon and Apple has asked India to rethink its proposed EU-like competition law, arguing regulations against data use and preferential treatment of partners could raise user costs

The proposed Indian legislation (PDF) is “much further in scope” than the EU’s, according to a tear-stained letter sent by the U.S. Chamber of Commerce’s U.S.-India Business Council to India’s Corporate Affairs Ministry.

Reuters explains

India’s “Digital Competition Bill” is on the lines of EU’s landmark Digital Markets Act 2022. It will apply to big firms, including those with a global turnover of over $30 billion and whose digital services have at least 10 million users locally, bringing some of the world’s biggest tech firms under its ambit.

It proposes to prohibit companies from exploiting non-public data of its users and promoting their own services over rivals, and also abolish restrictions on downloading of third-party apps.

Cynics might suggest that US Tech regards India as a potential sacred cash cow, given that its home markets are becoming saturated and China is notoriously harder to operate in. Reuters points out

With a population of 1.4 billion people and a growing affluent class, India is a lucrative market for big tech companies. Apple CEO Tim Cook said this month the company posted a “revenue record” in India during the March quarter, when its overall global revenue declined 4%.

The U.S.-India Business Council (whose directors include representatives of such trusted organisations as Boeing, Lockheed Martin, Meta, Google and Amway) is, of course, only thinking of Indian consumers:

“Targeted companies are likely to reduce investment in India, pass on increased prices for digital services, and reduce the range of services,” it says.

Naturally, that’s not to be interpreted as some sort of threat. Nope, that’s beloved captains of US Capitalism throwing their collective benign arms around Indian consumers, protectively. A heart-warming story for today’s troubled times.

Book review: Prophet’s Song by Paul Lynch

I mostly enjoyed this Booker-winning novel about a family in Ireland suffering under an increasingly authoritarian government, as the country swiftly descends into civil war. The politics aren’t fleshed out; it’s about the psychological effects of civil war and being a minority (in this case, the husband is a “disappeared” Trade Union leader). It’s very much a book of our time; this isn’t set in the “day after tomorrow”; it’s today. Apart from the street names and the Irish-accented dialogue, it could be set in Damascus or Darfur.

But what put me off what the author’s stylistic decision to avoid paragraphs or quotation marks. Much of the book was two pages of solid text, justified left and right so it was not at all easy on the eye. Here’s a photo of a random but representative spread:

A photo of a two pages from the  book

The lack of speech marks meant that often I couldn’t tell when one person’s reported speech ended and another participant in a conversation began, or when narration recommenced. For example, from the randomly chosen spread from the photo:

Carole looks up as the waitress steps towards them with a tray and places the drinks on the table then smiles and steps quickly away. You look as though you haven’t slept in a week, Eilish says, are you sleeping at all? Sleep, Carole says, her voice distant, far off in time, she looks across the table at Eilish without seeing her. I don’t sleep much at all, she says

(There were more egregious examples, but I left the book in my hotel room when I finished my holiday, as I knew I wouldn’t want to re-read it.)

The effect of this is that I would lose the thread and have to re-read to parse and make sense of the dialogue, and the monolithic slab of text made it difficult to find the place to re-read from. This was annoying, and got in the way of the excitement of the story.

I think this would be a great film or Netflix mini-series. Unfortunately, Lynch’s too-cool-for-punctuation prose got in the way of the narrative.

CSS :has(), the God Selector

Probably everybody knows this, but I didn’t and in case you don’t, here’s why the CSS :has() pseudo-class is omnipotent and so awe-inspiring I call it the God Selector.

I was working on a no-JavaScript fallback for a mobile hamburger menu, using the newly-baseline HTML Popover API. For users without JavaScript (and, yes, there are many), the code looks like this:

<header>
<a><picture> <!-- Logo homelink --> </picture></a>
<button> <!-- big fat CTA --> </button>
<search> .. </search>
<button popovertarget="narrowscreen-nav">Menu</button>
<nav id="narrowscreen-nav" popover> ... </nav>
</header>

I wanted to give the button a different style if its associated popover is shown. There is no pseudo-class for button:pressed (which is why some people like the checkbox hack, which is clever but has the wrong semantics. And, anyway, popovers can’t be triggered from inputs).

There is, however, a pseudo-class to tell you if a popover is open: :popover-open. Now, to find a way to style the button element by targetting this aspect of its associated (but not descendant) popover target element.

Sometimes people called :has a “parent selector”, but it’s not only that. I knew that it could “reach out” and look at siblings etc if there is the necessary CSS combinator. This selector worked for my code:

button:has(~nav:popover-open) {background-color: goldenrod;}

However, I wasn’t happy about it; what happens if the nav ceases to be a sibling (as it soon did, because I needed a wrapper around the stuff before the nav, to lay it out using Flexbox)? I tend to dislike handing code over to clients that has a very tight dependancy on exact markup structure.

Luckily, I had a conversation with the splendid Luke Warlow of Igalia (a free software consultancy/ hippie commune who do loads of work in all the browser engines), and he blew my mind. It turns out I was thinking about :has the wrong way round.

Behold the almighty God Selector:

:has(nav:popover-open) button[popovertarget] {background-colour:goldenrod;}

This is omnipotent because it doesn’t require any structural relationship between the thing being checked and the thing being styled. The first bit of the selector :has(nav:popover-open} doesn’t have a class, ID or element name, so is scoped to the root of the document. That’s the thing being checked: is there a nav that is an open popover anywhere in this page?

The second part of the selector is the thing to be styled, which is a descendant of the root – and, of course, everything on the page is a descendant of the html element, which is the root. Think of the selector as html:has(nav:popover-open) button[popovertarget] if that makes it easier to reason about.

Of course, you can narrow it down to hone in on the exact nav or button you’re interested in. For example,

header:has(nav:popover-open} button.letsBeSpecific[popovertarget] {background-color:goldenrod;}

And now, I’ve used the God Selector in three different places in the same stylesheet already, to achieve an effect I could not have done without handing over markup of much greater fragility. Thank you to the Mighty Luke Warlow, and I’ll have a kilo of whatever goes in the Igalia bong.

Reading List 318

(Last Updated on 20 May 2024)