@@ -18,6 +18,16 @@ enum RRWebPlayerConstants {
1818}
1919
2020actor RRWebEventGenerator {
21+ enum Dom {
22+ static let html = " html "
23+ static let head = " head "
24+ static let body = " body "
25+ static let lang = " lang "
26+ static let en = " en "
27+ static let style = " style "
28+ static let bodyStyle = " position:relative; "
29+ }
30+
2131 private var title : String
2232 private let padding = RRWebPlayerConstants . padding
2333 private var sid = 0
@@ -320,23 +330,23 @@ actor RRWebEventGenerator {
320330 return event
321331 }
322332
323- func fullSnapshotData( exportFrame: ExportFrame ) -> DomData {
333+ func fullSnapshotData( exportFrame: ExportFrame ) -> DomData {
324334 var rootNode = EventNode ( id: nextId, type: . Document)
325- let htmlDocNode = EventNode ( id: nextId, type: . DocumentType, name: " html " )
335+ let htmlDocNode = EventNode ( id: nextId, type: . DocumentType, name: Dom . html)
326336 rootNode. childNodes. append ( htmlDocNode)
327337 let firstImage = exportFrame. images [ 0 ]
328338 let base64String = firstImage. base64DataURL ( mimeType: exportFrame. mimeType)
329339
330- let headNode = EventNode ( id: nextId, type: . Element, tagName: " head " , attributes: [ : ] )
340+ let headNode = EventNode ( id: nextId, type: . Element, tagName: Dom . head, attributes: [ : ] )
331341 let currentBodyId = nextId
332342 let newImageId = nextId
333- let bodyNode = EventNode ( id: currentBodyId, type: . Element, tagName: " body " ,
334- attributes: [ " style " : " position:relative; " ] ,
343+ let bodyNode = EventNode ( id: currentBodyId, type: . Element, tagName: Dom . body,
344+ attributes: [ Dom . style: Dom . bodyStyle ] ,
335345 childNodes: [
336346 exportFrame. eventNode ( id: newImageId, rr_dataURL: base64String)
337347 ] )
338- let htmlNode = EventNode ( id: nextId, type: . Element, tagName: " html " ,
339- attributes: [ " lang " : " en " ] ,
348+ let htmlNode = EventNode ( id: nextId, type: . Element, tagName: Dom . html,
349+ attributes: [ Dom . lang: Dom . en ] ,
340350 childNodes: [ headNode, bodyNode] )
341351 imageId = newImageId
342352 bodyId = currentBodyId
0 commit comments