stop-observing


目录

title: 'Iconify SVG Framework Function: stopObserving'
functions:
  scan: './scan.md'
  observe: './observe.md'
  pauseObserver: './pause-observer.md'
  resumeObserver: './resume-observer.md'

SVG framework function: stopObserving

This tutorial is part of Iconify SVG Framework functions tutorial.

Function [func]stopObserving() tells SVG framework to stop watching HTML element for icon placeholders.

When to use this function:

Usage

Function has the following parameter:

Example

// Create element, start watching it.
function createNode() {
	let clicked = false;

	// Create element, set content.
	const node = document.createElement('a');
	node.innerHTML =
		'<span class="iconify" data-icon="carbon:circle-dash"></span>';

	// Change icon on click.
	node.addEventListener('click', () => {
		clicked = !clicked;
		node
			.querySelector('.iconify')
			.setAttribute(
				'data-icon',
				clicked ? 'carbon:circle-filled' : 'carbon:circle-dash'
			);
	});

	// Observe changes.
	// This is not needed if you are adding element to document.body because document.body is already
	// automatically watched. Use this if element is part of Shadow DOM or some other custom elements tree.
	Iconify.observe(node);

	return node;
}

// Stop watching element.
// Always stop observing element if you no longer need it!
// SVG framework doesn't know if you still need an element.
function removeNode(node) {
	Iconify.stopObserving(node);
}

版本号 #2
由 壳壳虫 创建于 2026-10-31 14:20:54 UTC
由 壳壳虫 更新于 2026-10-31 14:20:55 UTC