Skip to content

Commit ff72cfb

Browse files
committed
lint
1 parent fef8e0a commit ff72cfb

File tree

4 files changed

+25
-14
lines changed

4 files changed

+25
-14
lines changed

browser/diffDOM.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/diffDOM/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ interface DiffDOMOptions {
105105
maxDepth: number | false // False or a numeral. If set to a numeral, limits the level of depth that the the diff mechanism looks for differences. If false, goes through the entire tree.
106106
maxChildCount: number // False or a numeral. If set to a numeral, only does a simplified form of diffing of contents so that the number of diffs cannot be higher than the number of child nodes.
107107
valueDiffing: boolean // Whether to take into consideration the values of forms that differ from auto assigned values (when a user fills out a form).
108-
caseSensitive: boolean // Whether to preserve the case of an input string. Important when including CML (XHTML, SVG, etc.)
108+
caseSensitive: boolean // Whether to preserve the case of an input string. Important when including CML (XHTML, SVG, etc.)
109109
// syntax: textDiff: function (node, currentValue, expectedValue, newValue)
110110
textDiff: (
111111
node: textNodeType | Text | Comment,

src/diffDOM/virtual/apply.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { DiffDOMOptions, elementNodeType, nodeType, subsetType } from "../types"
22
import { Diff } from "../helpers"
3-
import {cleanNode} from "./helpers"
3+
import { cleanNode } from "./helpers"
44
// ===== Apply a virtual diff =====
55

66
function getFromVirtualRoute(tree: elementNodeType, route: number[]) {
@@ -280,7 +280,10 @@ function applyVirtualDiff(
280280
case options._const.addTextElement: {
281281
route = diff[options._const.route].slice()
282282
const c: number = route.splice(route.length - 1, 1)[0]
283-
newNode = {nodeName: "#text", data: diff[options._const.value]}
283+
newNode = {
284+
nodeName: "#text",
285+
data: diff[options._const.value],
286+
}
284287
node = getFromVirtualRoute(tree, route).node
285288
if (!node.childNodes) {
286289
node.childNodes = []

src/diffDOM/virtual/fromString.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ const parseTag = (tag: string, caseSensitive: boolean) => {
4646

4747
let tagMatch = tag.match(/<\/?([^\s]+?)[/\s>]/)
4848
if (tagMatch) {
49-
res.nodeName = (caseSensitive || tagMatch[1] === "svg") ? tagMatch[1] : tagMatch[1].toUpperCase()
49+
res.nodeName =
50+
caseSensitive || tagMatch[1] === "svg"
51+
? tagMatch[1]
52+
: tagMatch[1].toUpperCase()
5053
if (lookup[tagMatch[1]] || tag.charAt(tag.length - 2) === "/") {
5154
voidElement = true
5255
}
@@ -97,13 +100,17 @@ const parseTag = (tag: string, caseSensitive: boolean) => {
97100

98101
export const stringToObj = (
99102
html: string,
100-
options: DiffDOMOptionsPartial = { valueDiffing: true, caseSensitive: false }
103+
options: DiffDOMOptionsPartial = {
104+
valueDiffing: true,
105+
caseSensitive: false,
106+
}
101107
) => {
102108
const result: nodeType[] = []
103109
let current: { type: string; node: nodeType; voidElement: boolean }
104110
let level = -1
105111
const arr: { type: string; node: nodeType; voidElement: boolean }[] = []
106-
let inComponent = false, insideSvg = false
112+
let inComponent = false,
113+
insideSvg = false
107114

108115
// handle text at top level
109116
if (html.indexOf("<") !== 0) {
@@ -147,7 +154,7 @@ export const stringToObj = (
147154

148155
if (isOpen) {
149156
current = parseTag(tag, options.caseSensitive || insideSvg)
150-
if (current.node.nodeName==="svg") {
157+
if (current.node.nodeName === "svg") {
151158
insideSvg = true
152159
}
153160
level++
@@ -191,16 +198,17 @@ export const stringToObj = (
191198
if (!isOpen || current.voidElement) {
192199
if (
193200
level > -1 &&
194-
(
195-
current.voidElement ||
196-
(options.caseSensitive && current.node.nodeName === tag.slice(2, -1)) ||
197-
(!options.caseSensitive && current.node.nodeName.toUpperCase() === tag.slice(2, -1).toUpperCase())
198-
)
201+
(current.voidElement ||
202+
(options.caseSensitive &&
203+
current.node.nodeName === tag.slice(2, -1)) ||
204+
(!options.caseSensitive &&
205+
current.node.nodeName.toUpperCase() ===
206+
tag.slice(2, -1).toUpperCase()))
199207
) {
200208
level--
201209
// move current up a level to match the end tag
202210
if (level > -1) {
203-
if (current.node.nodeName==="svg") {
211+
if (current.node.nodeName === "svg") {
204212
insideSvg = false
205213
}
206214
current = arr[level]

0 commit comments

Comments
 (0)