Sha256: 8dc67a42fbb1060de3790ef41d8a25e5075f103f25b506e569534d0afe275a47

Contents?: true

Size: 736 Bytes

Versions: 7

Compression:

Stored size: 736 Bytes

Contents

import options from './options';
import { defer } from './util';
import { renderComponent } from './vdom/component';

/**
 * Managed queue of dirty components to be re-rendered
 * @type {Array<import('./component').Component>}
 */
let items = [];

/**
 * Enqueue a rerender of a component
 * @param {import('./component').Component} component The component to rerender
 */
export function enqueueRender(component) {
	if (!component._dirty && (component._dirty = true) && items.push(component)==1) {
		(options.debounceRendering || defer)(rerender);
	}
}

/** Rerender all enqueued dirty components */
export function rerender() {
	let p, list = items;
	items = [];
	while ( (p = list.pop()) ) {
		if (p._dirty) renderComponent(p);
	}
}

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
govuk_publishing_components-12.19.0 node_modules/preact/src/render-queue.js
govuk_publishing_components-12.18.0 node_modules/preact/src/render-queue.js
govuk_publishing_components-12.17.0 node_modules/preact/src/render-queue.js
govuk_publishing_components-12.16.0 node_modules/preact/src/render-queue.js
govuk_publishing_components-12.15.0 node_modules/preact/src/render-queue.js
govuk_publishing_components-12.14.1 node_modules/preact/src/render-queue.js
govuk_publishing_components-12.14.0 node_modules/preact/src/render-queue.js