import { DOMParser } from 'xmldom' ; import { TypedHash } from '@pnp/common' ; param { string } schemaXml param { Object } attributes param { Object } removeAttributes export function transformFieldXml ( schemaXml , attributes = { } , removeAttributes = [ 'Version' , 'SourceID' , 'Required' , 'WebId' , 'List' ] ) { const { documentElement } = new DOMParser ( ) . parseFromString ( schemaXml ) ; for ( let i = 0 ; i < removeAttributes . length ; i ++ ) { if ( documentElement . hasAttribute ( removeAttributes [ i ] ) ) documentElement . removeAttribute ( removeAttributes [ i ] ) ; } for ( let i = 0 ; i < Object . keys ( attributes ) . length ; i ++ ) { const key = Object . keys ( attributes ) [ i ] ; documentElement . setAttribute ( key , attributes [ key ] ) ; } return documentElement . toString ( ) ; }