ampproject / ampproject/amphtml

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

Open
#25,653 8 comments 0 reactions 1 assignee Claimed by @kristoferbaxter View on GitHub
Component: amp-script Stale Type: Bug WG: runtime
Dominant language
JavaScript
Stars
14.9k
Forks
4.1k
PR merge metrics
No merged PRs in 30d

Description

## 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.