@@ -58,7 +58,6 @@ describe('serializeNodeWithId', () => {
5858 let scope : SerializationScope
5959
6060 const getDefaultOptions = ( ) : SerializeOptions => ( {
61- parentNodePrivacyLevel : NodePrivacyLevel . ALLOW ,
6261 serializationContext : getDefaultSerializationContext ( ) ,
6362 configuration : DEFAULT_CONFIGURATION ,
6463 scope,
@@ -89,7 +88,9 @@ describe('serializeNodeWithId', () => {
8988 node : Element ,
9089 options : SerializeOptions | undefined = undefined
9190 ) : ( ElementNode & { id : number } ) | null {
92- return serializeNodeWithId ( node , options ?? getDefaultOptions ( ) ) as ( ElementNode & { id : number } ) | null
91+ return serializeNodeWithId ( node , NodePrivacyLevel . ALLOW , options ?? getDefaultOptions ( ) ) as
92+ | ( ElementNode & { id : number } )
93+ | null
9394 }
9495
9596 it ( 'serializes a div' , ( ) => {
@@ -670,7 +671,7 @@ describe('serializeNodeWithId', () => {
670671 )
671672
672673 const options = getDefaultOptions ( )
673- expect ( serializeNodeWithId ( linkNode , options ) ) . toEqual ( {
674+ expect ( serializeNodeWithId ( linkNode , NodePrivacyLevel . ALLOW , options ) ) . toEqual ( {
674675 type : NodeType . Element ,
675676 tagName : 'link' ,
676677 id : jasmine . any ( Number ) as unknown as number ,
@@ -700,7 +701,7 @@ describe('serializeNodeWithId', () => {
700701 } )
701702
702703 const options = getDefaultOptions ( )
703- expect ( serializeNodeWithId ( linkNode , options ) ) . toEqual ( {
704+ expect ( serializeNodeWithId ( linkNode , NodePrivacyLevel . ALLOW , options ) ) . toEqual ( {
704705 type : NodeType . Element ,
705706 tagName : 'link' ,
706707 id : jasmine . any ( Number ) as unknown as number ,
@@ -737,7 +738,7 @@ describe('serializeNodeWithId', () => {
737738 } )
738739
739740 const options = getDefaultOptions ( )
740- expect ( serializeNodeWithId ( linkNode , options ) ) . toEqual ( {
741+ expect ( serializeNodeWithId ( linkNode , NodePrivacyLevel . ALLOW , options ) ) . toEqual ( {
741742 type : NodeType . Element ,
742743 tagName : 'link' ,
743744 id : jasmine . any ( Number ) as unknown as number ,
@@ -762,7 +763,7 @@ describe('serializeNodeWithId', () => {
762763 parentEl . setAttribute ( PRIVACY_ATTR_NAME , PRIVACY_ATTR_VALUE_ALLOW )
763764 const textNode = document . createTextNode ( 'foo' )
764765 parentEl . appendChild ( textNode )
765- expect ( serializeNodeWithId ( textNode , getDefaultOptions ( ) ) ) . toEqual ( {
766+ expect ( serializeNodeWithId ( textNode , NodePrivacyLevel . ALLOW , getDefaultOptions ( ) ) ) . toEqual ( {
766767 type : NodeType . Text ,
767768 id : jasmine . any ( Number ) as unknown as number ,
768769 textContent : 'foo' ,
@@ -773,7 +774,7 @@ describe('serializeNodeWithId', () => {
773774 const parentEl = document . createElement ( 'bar' )
774775 const textNode = document . createTextNode ( '' )
775776 parentEl . appendChild ( textNode )
776- expect ( serializeNodeWithId ( textNode , getDefaultOptions ( ) ) ) . toEqual ( {
777+ expect ( serializeNodeWithId ( textNode , NodePrivacyLevel . ALLOW , getDefaultOptions ( ) ) ) . toEqual ( {
777778 type : NodeType . Text ,
778779 id : jasmine . any ( Number ) as unknown as number ,
779780 textContent : '' ,
@@ -784,15 +785,17 @@ describe('serializeNodeWithId', () => {
784785 const head = document . getElementsByTagName ( 'head' ) [ 0 ]
785786 const textNode = document . createTextNode ( ' ' )
786787 head . appendChild ( textNode )
787- expect ( serializeNodeWithId ( textNode , getDefaultOptions ( ) ) ) . toEqual ( null )
788+ expect ( serializeNodeWithId ( textNode , NodePrivacyLevel . ALLOW , getDefaultOptions ( ) ) ) . toEqual ( null )
788789 head . removeChild ( textNode )
789790 } )
790791 } )
791792
792793 describe ( 'CDATA nodes serialization' , ( ) => {
793794 it ( 'serializes a CDATA node' , ( ) => {
794795 const xmlDocument = new DOMParser ( ) . parseFromString ( '<root></root>' , 'text/xml' )
795- expect ( serializeNodeWithId ( xmlDocument . createCDATASection ( 'foo' ) , getDefaultOptions ( ) ) ) . toEqual ( {
796+ expect (
797+ serializeNodeWithId ( xmlDocument . createCDATASection ( 'foo' ) , NodePrivacyLevel . ALLOW , getDefaultOptions ( ) )
798+ ) . toEqual ( {
796799 type : NodeType . CDATA ,
797800 id : jasmine . any ( Number ) as unknown as number ,
798801 textContent : '' ,
@@ -802,47 +805,55 @@ describe('serializeNodeWithId', () => {
802805
803806 it ( 'adds serialized node ids to the provided Set' , ( ) => {
804807 const serializedNodeIds = new Set < number > ( )
805- const node = serializeNodeWithId ( document . createElement ( 'div' ) , { ...getDefaultOptions ( ) , serializedNodeIds } ) !
808+ const node = serializeNodeWithId ( document . createElement ( 'div' ) , NodePrivacyLevel . ALLOW , {
809+ ...getDefaultOptions ( ) ,
810+ serializedNodeIds,
811+ } ) !
806812 expect ( serializedNodeIds ) . toEqual ( new Set ( [ node . id ] ) )
807813 } )
808814
809815 describe ( 'ignores some nodes' , ( ) => {
810816 it ( 'does not save ignored nodes in the serializedNodeIds set' , ( ) => {
811817 const serializedNodeIds = new Set < number > ( )
812- serializeNodeWithId ( document . createElement ( 'script' ) , { ...getDefaultOptions ( ) , serializedNodeIds } )
818+ serializeNodeWithId ( document . createElement ( 'script' ) , NodePrivacyLevel . ALLOW , {
819+ ...getDefaultOptions ( ) ,
820+ serializedNodeIds,
821+ } )
813822 expect ( serializedNodeIds . size ) . toBe ( 0 )
814823 } )
815824
816825 it ( 'does not serialize ignored nodes' , ( ) => {
817826 const scriptElement = document . createElement ( 'script' )
818- serializeNodeWithId ( scriptElement , getDefaultOptions ( ) )
827+ serializeNodeWithId ( scriptElement , NodePrivacyLevel . ALLOW , getDefaultOptions ( ) )
819828 expect ( scope . nodeIds . get ( scriptElement ) ) . toBe ( undefined )
820829 } )
821830
822831 it ( 'ignores script tags' , ( ) => {
823- expect ( serializeNodeWithId ( document . createElement ( 'script' ) , getDefaultOptions ( ) ) ) . toEqual ( null )
832+ const scriptElement = document . createElement ( 'script' )
833+ expect ( serializeNodeWithId ( scriptElement , NodePrivacyLevel . ALLOW , getDefaultOptions ( ) ) ) . toEqual ( null )
824834 } )
825835
826836 it ( 'ignores comments' , ( ) => {
827- expect ( serializeNodeWithId ( document . createComment ( 'foo' ) , getDefaultOptions ( ) ) ) . toEqual ( null )
837+ const commentNode = document . createComment ( 'foo' )
838+ expect ( serializeNodeWithId ( commentNode , NodePrivacyLevel . ALLOW , getDefaultOptions ( ) ) ) . toEqual ( null )
828839 } )
829840
830841 it ( 'ignores link favicons' , ( ) => {
831842 const linkElement = document . createElement ( 'link' )
832843 linkElement . setAttribute ( 'rel' , 'shortcut icon' )
833- expect ( serializeNodeWithId ( linkElement , getDefaultOptions ( ) ) ) . toEqual ( null )
844+ expect ( serializeNodeWithId ( linkElement , NodePrivacyLevel . ALLOW , getDefaultOptions ( ) ) ) . toEqual ( null )
834845 } )
835846
836847 it ( 'ignores meta keywords' , ( ) => {
837848 const metaElement = document . createElement ( 'meta' )
838849 metaElement . setAttribute ( 'name' , 'keywords' )
839- expect ( serializeNodeWithId ( metaElement , getDefaultOptions ( ) ) ) . toEqual ( null )
850+ expect ( serializeNodeWithId ( metaElement , NodePrivacyLevel . ALLOW , getDefaultOptions ( ) ) ) . toEqual ( null )
840851 } )
841852
842853 it ( 'ignores meta name attribute casing' , ( ) => {
843854 const metaElement = document . createElement ( 'meta' )
844855 metaElement . setAttribute ( 'name' , 'KeYwOrDs' )
845- expect ( serializeNodeWithId ( metaElement , getDefaultOptions ( ) ) ) . toEqual ( null )
856+ expect ( serializeNodeWithId ( metaElement , NodePrivacyLevel . ALLOW , getDefaultOptions ( ) ) ) . toEqual ( null )
846857 } )
847858 } )
848859
@@ -994,7 +1005,6 @@ describe('serializeDocumentNode handles', function testAllowDomTree() {
9941005 let scope : SerializationScope
9951006
9961007 const getDefaultOptions = ( ) : SerializeOptions => ( {
997- parentNodePrivacyLevel : NodePrivacyLevel . ALLOW ,
9981008 serializationContext : getDefaultSerializationContext ( ) ,
9991009 configuration : DEFAULT_CONFIGURATION ,
10001010 scope,
@@ -1036,13 +1046,9 @@ describe('serializeDocumentNode handles', function testAllowDomTree() {
10361046 } )
10371047
10381048 it ( 'a masked DOM Document itself is still serialized ' , ( ) => {
1039- const serializeOptionsMask : SerializeOptions = {
1040- ...getDefaultOptions ( ) ,
1041- parentNodePrivacyLevel : NodePrivacyLevel . MASK ,
1042- }
1043- expect ( serializeDocumentNode ( document , serializeOptionsMask ) ) . toEqual ( {
1049+ expect ( serializeDocumentNode ( document , NodePrivacyLevel . MASK , getDefaultOptions ( ) ) ) . toEqual ( {
10441050 type : NodeType . Document ,
1045- childNodes : serializeChildNodes ( document , serializeOptionsMask ) ,
1051+ childNodes : serializeChildNodes ( document , NodePrivacyLevel . MASK , getDefaultOptions ( ) ) ,
10461052 adoptedStyleSheets : undefined ,
10471053 } )
10481054 } )
0 commit comments