Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: preactjs/preact
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 10.19.3
Choose a base ref
...
head repository: preactjs/preact
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 10.19.4
Choose a head ref

Commits on Dec 14, 2023

  1. Improve types of hook source (#4229)

    * Improve hook src typings
    
    * Use `unknown` instead of `any` when we explicitly don't know the type
    
    Also improve typings of options used in hooks
    
    * Add return types to functions
    andrewiggins authored Dec 14, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    4f2a04f View commit details

Commits on Dec 18, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    ef57c62 View commit details
  2. run commit callbacks within the render queue to ensure render->effect…

    …->render is collapsed to one flush
    developit committed Dec 18, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    926b8c8 View commit details
  3. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    5eab018 View commit details
  4. size optimization

    developit committed Dec 18, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    b39e0bc View commit details

Commits on Dec 21, 2023

  1. Add ComponentType to preact/compat

    Add the `ComponentType` type that represents a class or function component with optional props to mirror the same type in `@types/react`: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/0818c3f7de545c6b6431e9745dd9910618bba918/types/react/index.d.ts#L43
    ianobermiller authored Dec 21, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    ed78832 View commit details

Commits on Dec 22, 2023

  1. Export existing type instad

    Co-authored-by: Ryan Christian <33403762+rschristian@users.noreply.github.com>
    ianobermiller and rschristian authored Dec 22, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    c6d1062 View commit details
  2. Update index.d.ts

    rschristian authored Dec 22, 2023
    Copy the full SHA
    be2ca05 View commit details
  3. Copy the full SHA
    f963509 View commit details

Commits on Dec 27, 2023

  1. Copy the full SHA
    bbe6757 View commit details
  2. Merge pull request #4242 from preactjs/missing-inherit

    TS: Add missing contenteditable "inherit" value
    marvinhagemeister authored Dec 27, 2023
    Copy the full SHA
    da9d488 View commit details

Commits on Dec 29, 2023

  1. Copy the full SHA
    e20029d View commit details
  2. Copy the full SHA
    899e9d9 View commit details

Commits on Jan 2, 2024

  1. Copy the full SHA
    13b0afb View commit details
  2. Copy the full SHA
    e1f0d3e View commit details
  3. Update src/component.js

    Co-authored-by: Jovi De Croock <decroockjovi@gmail.com>
    developit and JoviDeCroock authored Jan 2, 2024
    Copy the full SHA
    5f6d63e View commit details
  4. Copy the full SHA
    fe0df55 View commit details

Commits on Jan 3, 2024

  1. Copy the full SHA
    b09f4c1 View commit details

Commits on Jan 5, 2024

  1. Merge pull request #4234 from preactjs/multi-root-shared-commit

    WIP: batch commit callbacks from all components in the render queue
    developit authored Jan 5, 2024
    Copy the full SHA
    f7ccb90 View commit details

Commits on Jan 16, 2024

  1. safari 12.3 fix (#4253)

    JoviDeCroock authored Jan 16, 2024
    Copy the full SHA
    b3480e8 View commit details

Commits on Jan 22, 2024

  1. Copy the full SHA
    79be156 View commit details

Commits on Jan 29, 2024

  1. Copy the full SHA
    49433b3 View commit details

Commits on Feb 2, 2024

  1. Copy the full SHA
    a3f7c33 View commit details

Commits on Feb 8, 2024

  1. 10.19.4 (#4273)

    JoviDeCroock authored Feb 8, 2024
    Copy the full SHA
    6992228 View commit details
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -47,6 +47,7 @@ jobs:
npm run test:unit
- name: Coveralls GitHub Action
uses: coverallsapp/github-action@v2.1.2
timeout-minutes: 2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Package
1 change: 1 addition & 0 deletions .github/workflows/saucelabs.yml
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@ jobs:
cache-dependency-path: '**/package-lock.json'
- run: npm ci
- name: test
timeout-minutes: 20
env:
CI: true
COVERAGE: true
3 changes: 2 additions & 1 deletion compat/src/PureComponent.js
Original file line number Diff line number Diff line change
@@ -4,8 +4,9 @@ import { shallowDiffers } from './util';
/**
* Component class with a predefined `shouldComponentUpdate` implementation
*/
export function PureComponent(p) {
export function PureComponent(p, c) {
this.props = p;
this.context = c;
}
PureComponent.prototype = new Component();
// Some third-party libraries check if this property is present
10 changes: 10 additions & 0 deletions compat/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -46,6 +46,8 @@ declare namespace React {
export import RefObject = preact.RefObject;
export import Component = preact.Component;
export import FunctionComponent = preact.FunctionComponent;
export import ComponentType = preact.ComponentType;
export import ComponentClass = preact.ComponentClass;
export import FC = preact.FunctionComponent;
export import createContext = preact.createContext;
export import createRef = preact.createRef;
@@ -54,6 +56,8 @@ declare namespace React {
export import cloneElement = preact.cloneElement;
export import ComponentProps = preact.ComponentProps;
export import ReactNode = preact.ComponentChild;
export import ReactElement = preact.VNode;
export import Consumer = preact.Consumer;

// Suspense
export import Suspense = _Suspense.Suspense;
@@ -168,6 +172,12 @@ declare namespace React {
| MutableRefObject<T | null>
| null;

export type ComponentPropsWithRef<
C extends ComponentType<any> | keyof JSXInternal.IntrinsicElements
> = C extends (new(props: infer P) => Component<any, any>)
? PropsWithoutRef<P> & RefAttributes<InstanceType<C>>
: ComponentProps<C>;

export function flushSync<R>(fn: () => R): R;
export function flushSync<A, R>(fn: (a: A) => R, a: A): R;

32 changes: 32 additions & 0 deletions compat/test/browser/PureComponent.test.js
Original file line number Diff line number Diff line change
@@ -37,6 +37,38 @@ describe('PureComponent', () => {
expect(spy).to.be.calledWithMatch(expected, expected);
});

it('should pass context in constructor', () => {
let instance;
// Not initializing state matches React behavior: https://codesandbox.io/s/rml19v8o2q
class Foo extends React.PureComponent {
constructor(props, context) {
super(props, context);
expect(this.props).to.equal(props);
expect(this.state).to.deep.equal(undefined);
expect(this.context).to.equal(context);

instance = this;
}
render(props) {
return <div {...props}>Hello</div>;
}
}

sinon.spy(Foo.prototype, 'render');

const PROPS = { foo: 'bar' };
React.render(<Foo {...PROPS} />, scratch);

expect(Foo.prototype.render)
.to.have.been.calledOnce.and.to.have.been.calledWithMatch(PROPS, {}, {})
.and.to.have.returned(sinon.match({ type: 'div', props: PROPS }));
expect(instance.props).to.deep.equal(PROPS);
expect(instance.state).to.deep.equal({});
expect(instance.context).to.deep.equal({});

expect(scratch.innerHTML).to.equal('<div foo="bar">Hello</div>');
});

it('should ignore the __source variable', () => {
const pureSpy = sinon.spy();
const appSpy = sinon.spy();
23 changes: 22 additions & 1 deletion compat/test/browser/events.test.js
Original file line number Diff line number Diff line change
@@ -2,7 +2,8 @@ import { render } from 'preact';
import {
setupScratch,
teardown,
createEvent
createEvent,
supportsPassiveEvents
} from '../../../test/_util/helpers';

import React, { createElement } from 'preact/compat';
@@ -309,4 +310,24 @@ describe('preact/compat events', () => {
scratch.firstChild.dispatchEvent(createEvent('focusout'));
expect(spy).to.be.calledOnce;
});

if (supportsPassiveEvents()) {
it('should use capturing for event props ending with *Capture', () => {
let click = sinon.spy();

render(
<div onTouchMoveCapture={click}>
<button type="button">Click me</button>
</div>,
scratch
);

expect(proto.addEventListener).to.have.been.calledOnce;
expect(proto.addEventListener).to.have.been.calledWithExactly(
'touchmove',
sinon.match.func,
true
);
});
}
});
5 changes: 1 addition & 4 deletions compat/test/browser/useSyncExternalStore.test.js
Original file line number Diff line number Diff line change
@@ -658,10 +658,7 @@ describe('useSyncExternalStore', () => {
await act(() => {
store.set(1);
});
// Preact logs differ from React here cuz of how we do rerendering. We
// rerender subtrees and then commit effects so Child2 never sees the
// update to 1 cuz Child1 rerenders and runs its layout effects first.
assertLog([1, /*1,*/ 'Reset back to 0', 0, 0]);
assertLog([1, 1, 'Reset back to 0', 0, 0]);
expect(container.textContent).to.equal('00');
});

2 changes: 1 addition & 1 deletion devtools/src/devtools.js
Original file line number Diff line number Diff line change
@@ -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.19.3', options, {
window.__PREACT_DEVTOOLS__.attachPreact('10.19.4', options, {
Fragment,
Component
});
Loading