* Preserve source maps for `@apply` * Overwrite the source for all cloned descendants * Preserve source maps when expanding defaults * Verify that source maps are correctly generated * Update changelog
17 lines
322 B
JavaScript
17 lines
322 B
JavaScript
export default function cloneNodes(nodes, source) {
|
|
return nodes.map((node) => {
|
|
let cloned = node.clone()
|
|
|
|
if (source !== undefined) {
|
|
cloned.source = source
|
|
|
|
if ('walk' in cloned) {
|
|
cloned.walk((child) => {
|
|
child.source = source
|
|
})
|
|
}
|
|
}
|
|
|
|
return cloned
|
|
})
|
|
}
|