bootstrap-input-spinner 5.0.6 → 5.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/InputSpinner.js +4 -4
- package/test/TestInputSpinner.js +22 -0
package/package.json
CHANGED
package/src/InputSpinner.js
CHANGED
|
@@ -46,8 +46,6 @@ const I18nEditor = function (props, element) {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
let triggerKeyPressed = false
|
|
50
|
-
|
|
51
49
|
function parseTemplate(html) {
|
|
52
50
|
const tpl = document.createElement("template")
|
|
53
51
|
tpl.innerHTML = html.trim()
|
|
@@ -159,6 +157,8 @@ export class InputSpinner {
|
|
|
159
157
|
destroy()
|
|
160
158
|
}
|
|
161
159
|
|
|
160
|
+
let triggerKeyPressed = false
|
|
161
|
+
|
|
162
162
|
this.observer = new MutationObserver(function () {
|
|
163
163
|
updateAttributes()
|
|
164
164
|
setValue(self.value, true)
|
|
@@ -364,9 +364,9 @@ export class InputSpinner {
|
|
|
364
364
|
}
|
|
365
365
|
const originalClass = self.original.className || ""
|
|
366
366
|
let groupClass = ""
|
|
367
|
-
if (/form-control-sm
|
|
367
|
+
if (/form-control-sm/.test(originalClass)) {
|
|
368
368
|
groupClass = "input-group-sm"
|
|
369
|
-
} else if (/form-control-lg
|
|
369
|
+
} else if (/form-control-lg/.test(originalClass)) {
|
|
370
370
|
groupClass = "input-group-lg"
|
|
371
371
|
}
|
|
372
372
|
const inputClass = originalClass.replace(/form-control(-(sm|lg))?/g, "")
|
package/test/TestInputSpinner.js
CHANGED
|
@@ -341,6 +341,28 @@ describe("InputSpinner instance isolation", () => {
|
|
|
341
341
|
assert.equal(b, 0)
|
|
342
342
|
clear()
|
|
343
343
|
})
|
|
344
|
+
it("two spinners both respond to keyboard activation while the other is held", () => {
|
|
345
|
+
const elA = createInput({value: "0", min: "0", max: "10", step: "1"})
|
|
346
|
+
const elB = createInput({value: "0", min: "0", max: "10", step: "1"})
|
|
347
|
+
new InputSpinner(elA, {autoInterval: undefined})
|
|
348
|
+
new InputSpinner(elB, {autoInterval: undefined})
|
|
349
|
+
const btnA = elA.nextElementSibling.querySelector(".btn-increment")
|
|
350
|
+
const btnB = elB.nextElementSibling.querySelector(".btn-increment")
|
|
351
|
+
const make = (type) => {
|
|
352
|
+
const e = new KeyboardEvent(type, {key: " ", bubbles: true})
|
|
353
|
+
Object.defineProperty(e, "keyCode", {value: 32})
|
|
354
|
+
return e
|
|
355
|
+
}
|
|
356
|
+
const down = () => make("keydown")
|
|
357
|
+
const up = () => make("keyup")
|
|
358
|
+
btnA.dispatchEvent(down())
|
|
359
|
+
assert.equal(elA.value, "1")
|
|
360
|
+
// B's keydown must still register even though A's keyup hasn't fired.
|
|
361
|
+
btnB.dispatchEvent(down())
|
|
362
|
+
assert.equal(elB.value, "1")
|
|
363
|
+
document.body.dispatchEvent(up())
|
|
364
|
+
clear()
|
|
365
|
+
})
|
|
344
366
|
})
|
|
345
367
|
|
|
346
368
|
describe("InputSpinner attribute observation", () => {
|