ampproject / ampproject/amphtml

amp-script: blur() and focus() events not working on HTMLInputElement

Offen
#25,653 8 Kommentare 0 Reaktionen 1 zugewiesene Person Beansprucht von @kristoferbaxter Auf GitHub ansehen
Component: amp-script Stale Type: Bug WG: runtime
Vorherrschende Sprache
JavaScript
Sterne
14.9k
Forks
4.1k
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

## What's the issue?

The `blur()` and `focus()` events on `HTMLInputElement` ought to be supported in amp-script, according to the API compatibility table here: [https://github.com/ampproject/worker-dom/blob/master/web_compat_table.md](https://github.com/ampproject/worker-dom/blob/master/web_compat_table.md)

But, they don't appear to be, based on console messages when calling`.blur()` or `.focus()`:

`TypeError: input.blur is not a function. (In 'input.blur()', 'input.blur' is undefined)`

Worth noting that the table specifies `focus()` and `blur()` only for `HTMLInputElement`s, not for generic `HTMLElement`s or anything else. It still doesn't appear to work for `HTMLInputElement`s, though.

## How do we reproduce the issue?

Here's a simple example:

```


Try me

document.querySelector(".demo-button").addEventListener("click", () => {
document.querySelector(".demo-input").blur();
});

```

## What browsers are affected?

Tested on macOS in Safari v13.0.2 & Chrome 78.0.3904.97 (64-bit)

## Which AMP version is affected?

Version 1911070201440; I'm not sure whether it's ever worked in previous versions.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.