update()

in src/Bootstrapper.js [162:202]


	update(node, cb = null) {
		// Check if we have a container before attempting an update
		if (!this.__container__) {
			_callback(cb);
			return;
		}

		const target = node || window.document.body;
		const query = target.querySelectorAll(`[${this.componentSelector}]`);

		if (!query.length) {
			// Nothing to update
			return;
		}

		// Lifecycle event
		// Hook to allow developers to cancel operation
		if (typeof this.shouldUpdate === 'function') {
			if (this.shouldUpdate(target, query) === false) {
				_callback(cb, this);
				return;
			}
		}

		// Lifecycle event
		if (typeof this.willUpdate === 'function') {
			this.willUpdate(target, query);
		}

		this._apply(
			query,
			() => {
				// Lifecycle event
				if (typeof this.didUpdate === 'function') {
					this.didUpdate(target);
				}

				_callback(cb, this);
			},
		);
	}