MCPcopy
hub / github.com/webpack/webpack / insertAtPlace

Function insertAtPlace

lib/html/syntax.js:4795–4814  ·  view source on GitHub ↗
(
		/** @type {InsertionPlace} */ place,
		/** @type {HtmlNode} */ node
	)

Source from the content-addressed store, hash-verified

4793 };
4794
4795 const insertAtPlace = (
4796 /** @type {InsertionPlace} */ place,
4797 /** @type {HtmlNode} */ node
4798 ) => {
4799 if (place.beforeNode) {
4800 const arr = childrenOf(place.parent);
4801 const idx = arr.indexOf(place.beforeNode);
4802 if (
4803 node.type === NodeType.Text &&
4804 idx > 0 &&
4805 arr[idx - 1].type === NodeType.Text
4806 ) {
4807 /** @type {HtmlText} */ (arr[idx - 1]).data += node.data;
4808 return;
4809 }
4810 arr.splice(idx, 0, node);
4811 } else {
4812 appendTo(place.parent, node);
4813 }
4814 };
4815
4816 const insertCharacters = (
4817 /** @type {string} */ data,

Callers 5

insertCommentFunction · 0.85
insertHtmlElementFunction · 0.85
insertForeignElementFunction · 0.85
reconstructAfeFunction · 0.85
adoptionAgencyFunction · 0.85

Calls 2

childrenOfFunction · 0.85
appendToFunction · 0.85

Tested by

no test coverage detected