Skip to content

Commit 135e672

Browse files
committed
introduce constants
1 parent ca9a893 commit 135e672

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

Sources/LaunchDarklySessionReplay/Exporter/RRWebEventGenerator.swift

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ enum RRWebPlayerConstants {
1818
}
1919

2020
actor 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

Comments
 (0)