Skip to content

Commit 3317356

Browse files
jenstroegermarcbachmann
authored andcommitted
refactor(selection): Unify tag name and selector arguments.
1 parent eb02a88 commit 3317356

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

src/content.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -303,19 +303,17 @@ export function removeFormattingElem (host, range, elem) {
303303
})
304304
}
305305

306-
export function removeFormatting (host, range, tagName, selector) {
306+
export function removeFormatting (host, range, selector) {
307307
return restoreRange(host, range, () => {
308-
nuke(host, range, tagName, selector)
308+
nuke(host, range, selector)
309309
})
310310
}
311311

312312
// Unwrap all tags this range is affected by.
313313
// Can also affect content outside of the range.
314-
export function nuke (host, range, tagName, selector) {
314+
export function nuke (host, range, selector) {
315315
getTags(host, range).forEach((elem) => {
316-
if (elem.nodeName.toUpperCase() !== 'BR' &&
317-
(!tagName || (elem.nodeName.toUpperCase() === tagName.toUpperCase() &&
318-
(!selector || elem.matches(selector))))) {
316+
if (elem.nodeName.toUpperCase() !== 'BR' && (!selector || elem.matches(selector))) {
319317
unwrap(elem)
320318
}
321319
})

src/selection.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,11 @@ export default class Selection extends Cursor {
203203
}
204204
}
205205

206-
// @param {String} tagName. E.g. 'a' to remove all links; if undefined, remove all.
207-
// @param {String} selector. E.g. '.foo' or '[data-foo]' to remove all links 'a.foo'
208-
// or 'a[data-foo]; if undefined, disregard the selector.
209-
removeFormatting (tagName, selector) {
210-
this.range = content.removeFormatting(this.host, this.range, tagName, selector)
206+
// @param {String} selector. An element selector, e.g. 'a' or 'span.some-class'
207+
// that represents elements to be removed; if undefined,
208+
// remove all.
209+
removeFormatting (selector) {
210+
this.range = content.removeFormatting(this.host, this.range, selector)
211211
this.setSelection()
212212
}
213213

0 commit comments

Comments
 (0)