Skip to content

Commit 6a585f9

Browse files
scrhartleyscrhartley
andauthored
Get rid of latest usages of substr (#3074)
* Replace latest usages of substr * Replace usage of substr in tests --------- Co-authored-by: scrhartley <scrhartley@github.com>
1 parent 05d37e6 commit 6a585f9

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/htmx.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,17 +1150,17 @@ var htmx = (function() {
11501150
const selector = normalizeSelector(parts.shift())
11511151
let item
11521152
if (selector.indexOf('closest ') === 0) {
1153-
item = closest(asElement(elt), normalizeSelector(selector.substr(8)))
1153+
item = closest(asElement(elt), normalizeSelector(selector.slice(8)))
11541154
} else if (selector.indexOf('find ') === 0) {
1155-
item = find(asParentNode(elt), normalizeSelector(selector.substr(5)))
1155+
item = find(asParentNode(elt), normalizeSelector(selector.slice(5)))
11561156
} else if (selector === 'next' || selector === 'nextElementSibling') {
11571157
item = asElement(elt).nextElementSibling
11581158
} else if (selector.indexOf('next ') === 0) {
1159-
item = scanForwardQuery(elt, normalizeSelector(selector.substr(5)), !!global)
1159+
item = scanForwardQuery(elt, normalizeSelector(selector.slice(5)), !!global)
11601160
} else if (selector === 'previous' || selector === 'previousElementSibling') {
11611161
item = asElement(elt).previousElementSibling
11621162
} else if (selector.indexOf('previous ') === 0) {
1163-
item = scanBackwardsQuery(elt, normalizeSelector(selector.substr(9)), !!global)
1163+
item = scanBackwardsQuery(elt, normalizeSelector(selector.slice(9)), !!global)
11641164
} else if (selector === 'document') {
11651165
item = document
11661166
} else if (selector === 'window') {

test/util/util.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ function parseParams(str) {
7171
}
7272
var params = {}; var e
7373
if (str) {
74-
if (str.substr(0, 1) == '?') {
75-
str = str.substr(1)
74+
if (str.slice(0, 1) == '?') {
75+
str = str.slice(1)
7676
}
7777
while (e = re.exec(str)) {
7878
var k = decode(e[1])

0 commit comments

Comments
 (0)