Skip to content

Fix tests yielding false positives. - #372

Merged
theengineear merged 1 commit into
mainfrom
fix-faulty-tests
Jul 31, 2026
Merged

theengineear merged 1 commit into
mainfrom
fix-faulty-tests

Conversation

@theengineear

Copy link
Copy Markdown
Collaborator

A couple of tests were not really testing anything due to using = instead of === inside the assert call.

One test remained passing, the other needed an update, which is described below.

// old test code
html`<div .onclick="${'function() { this.textContent = \'…hi\u2026\'; }'}"></div>`
// new test code
html`<div .onclick="${function() { this.textContent = '…hi\u2026'; }}"></div>`

The old test code never quite made sense as according to the specification, a string would be coerced to null and then of course no event handling would occur (which happens as expected).

In other words…

element.onclick = () => { console.log('hi'); }
element.onclick
// () => { console.log('hi'); }
element.click();
// hi

element.onclick = "() => { console.log('hi'); }"
element.onclick
// null
element.click();
// (nothing is logged)

Closes #371.

A couple of tests were not really testing anything due to using `=`
instead of `===` inside the `assert` call.

One test remained passing, the other needed an update, which is
described below.

```js
// old test code
html`<div .onclick="${'function() { this.textContent = \'…hi\u2026\'; }'}"></div>`
```

```js
// new test code
html`<div .onclick="${function() { this.textContent = '…hi\u2026'; }}"></div>`
```

The old test code never quite made sense as according to the
[specification](https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-attributes),
a string would be coerced to `null` and then of course no event handling
would occur (which happens as expected).

In other words…

```js
element.onclick = () => { console.log('hi'); }
element.onclick
// () => { console.log('hi'); }
element.click();
// hi

element.onclick = "() => { console.log('hi'); }"
element.onclick
// null
element.click();
// (nothing is logged)
```

Closes #371.
@theengineear
theengineear merged commit b4333bb into main Jul 31, 2026
1 check passed
@theengineear
theengineear deleted the fix-faulty-tests branch July 31, 2026 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Faulty test assertions

1 participant