Skip to content

Commit

Permalink
Merge branch 'master' into types/compat-forward-ref-exotic-component
Browse files Browse the repository at this point in the history
  • Loading branch information
rschristian authored May 17, 2023
2 parents 93bf0e6 + 19f4176 commit a24d26b
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
npm run lint
npm run test:unit
- name: Coveralls GitHub Action
uses: coverallsapp/github-action@1.1.3
uses: coverallsapp/github-action@v2.1.2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Package
Expand Down
2 changes: 1 addition & 1 deletion compat/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ declare namespace React {

export function createPortal(
vnode: preact.VNode,
container: Element
container: Element | DocumentFragment
): preact.VNode<any>;

export function render(
Expand Down
4 changes: 2 additions & 2 deletions compat/src/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ options.event = e => {
*/
function afterEvent(eventType, target) {
if (target.value != null) {
target.value = target._prevValue;
Promise.resolve().then(() => (target.value = target._prevValue));
}
if (eventType === 'change' && target.checked != null) {
target.checked = target._prevValue;
Promise.resolve().then(() => (target.checked = target._prevValue));
}
}

Expand Down
4 changes: 3 additions & 1 deletion compat/test/browser/controlledInput.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ describe('preact/compat controlled inputs', () => {
render(<Input />, scratch);

scratch.firstChild.value = 'A';
fireEvent(scratch.firstChild, 'change');
await fireEvent(scratch.firstChild, 'change');
expect(calls).to.deep.equal(['A']);
expect(scratch.firstChild.value).to.equal('A');

Expand Down Expand Up @@ -208,6 +208,8 @@ describe('preact/compat controlled inputs', () => {

scratch.firstChild.checked = false;
await fireEvent(scratch.firstChild, 'change');
// Have to wait for the microtick
await new Promise(res => setTimeout(res));
expect(calls).to.deep.equal([false]);
expect(scratch.firstChild.checked).to.equal(true);
});
Expand Down
2 changes: 1 addition & 1 deletion devtools/src/devtools.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { options, Fragment, Component } from 'preact';

export function initDevTools() {
if (typeof window != 'undefined' && window.__PREACT_DEVTOOLS__) {
window.__PREACT_DEVTOOLS__.attachPreact('10.13.2', options, {
window.__PREACT_DEVTOOLS__.attachPreact('10.14.1', options, {
Fragment,
Component
});
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "preact",
"amdName": "preact",
"version": "10.13.2",
"version": "10.14.1",
"private": false,
"description": "Fast 3kb React-compatible Virtual DOM library.",
"main": "dist/preact.js",
Expand Down
2 changes: 2 additions & 0 deletions src/diff/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ export function setProperty(dom, name, value, oldValue, isSvg) {
// cast to `0` instead
name !== 'tabIndex' &&
name !== 'download' &&
name !== 'rowSpan' &&
name !== 'colSpan' &&
name in dom
) {
try {
Expand Down
2 changes: 1 addition & 1 deletion src/jsx.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2097,7 +2097,7 @@ export namespace JSXInternal {
animate: SVGAttributes<SVGAnimateElement>;
circle: SVGAttributes<SVGCircleElement>;
animateMotion: SVGAttributes<SVGAnimateMotionElement>;
animateTransform: SVGAttributes<SVGAnimateElement>;
animateTransform: SVGAttributes<SVGAnimateTransformElement>;
clipPath: SVGAttributes<SVGClipPathElement>;
defs: SVGAttributes<SVGDefsElement>;
desc: SVGAttributes<SVGDescElement>;
Expand Down
42 changes: 42 additions & 0 deletions test/browser/render.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,48 @@ describe('render()', () => {
});
}

// Test for #3969
it('should clear rowspan and colspan', () => {
let update;
class App extends Component {
constructor(props) {
super(props);
this.state = { active: true };
update = this.setState.bind(this);
}

render() {
return (
<div>
{this.state.active ? (
<table>
<tr>
<td rowSpan={2} colSpan={2}>
Foo
</td>
</tr>
</table>
) : (
<table>
<tr>
<td>Foo</td>
</tr>
</table>
)}
</div>
);
}
}

render(<App />, scratch);

update({ active: false });
rerender();

expect(scratch.querySelector('td[rowspan]')).to.equal(null);
expect(scratch.querySelector('td[colspan]')).to.equal(null);
});

// Test for preactjs/preact#651
it('should set enumerable boolean attribute', () => {
render(<input spellcheck={false} />, scratch);
Expand Down

0 comments on commit a24d26b

Please sign in to comment.