MCPcopy Index your code
hub / github.com/postcss/postcss / replaceWith

Method replaceWith

lib/node.js:352–373  ·  view source on GitHub ↗
(...nodes)

Source from the content-addressed store, hash-verified

350 }
351
352 replaceWith(...nodes) {
353 if (this.parent) {
354 let bookmark = this
355 let foundSelf = false
356 for (let node of nodes) {
357 if (node === this) {
358 foundSelf = true
359 } else if (foundSelf) {
360 this.parent.insertAfter(bookmark, node)
361 bookmark = node
362 } else {
363 this.parent.insertBefore(bookmark, node)
364 }
365 }
366
367 if (!foundSelf) {
368 this.remove()
369 }
370 }
371
372 return this
373 }
374
375 root() {
376 let result = this

Callers 5

DeclarationFunction · 0.80
prepareFunction · 0.80
visitor.test.tsFile · 0.80
node.test.tsFile · 0.80
pluginFunction · 0.80

Calls 3

removeMethod · 0.95
insertAfterMethod · 0.80
insertBeforeMethod · 0.80

Tested by 2

DeclarationFunction · 0.64
prepareFunction · 0.64