prep 1.9.7 release

This commit is contained in:
Carson Gross 2023-11-02 16:43:18 -06:00
parent 8ddd079b90
commit 61dac7d933
5 changed files with 20 additions and 4 deletions

View File

@ -5,6 +5,11 @@
var attrPrefix = 'hx-target-'; var attrPrefix = 'hx-target-';
// IE11 doesn't support string.startsWith
function startsWith(str, prefix) {
return str.substring(0, prefix.length) === prefix
}
/** /**
* @param {HTMLElement} elt * @param {HTMLElement} elt
* @param {number} respCode * @param {number} respCode
@ -38,7 +43,7 @@
'***', '***',
'xxx', 'xxx',
]; ];
if (respCode.startsWith('4') || respCode.startsWith('5')) { if (startsWith(respCode, '4') || startsWith(respCode, '5')) {
attrPossibilities.push('error'); attrPossibilities.push('error');
} }

View File

@ -5,6 +5,11 @@
var attrPrefix = 'hx-target-'; var attrPrefix = 'hx-target-';
// IE11 doesn't support string.startsWith
function startsWith(str, prefix) {
return str.substring(0, prefix.length) === prefix
}
/** /**
* @param {HTMLElement} elt * @param {HTMLElement} elt
* @param {number} respCode * @param {number} respCode
@ -38,7 +43,7 @@
'***', '***',
'xxx', 'xxx',
]; ];
if (respCode.startsWith('4') || respCode.startsWith('5')) { if (startsWith(respCode, '4') || startsWith(respCode, '5')) {
attrPossibilities.push('error'); attrPossibilities.push('error');
} }

View File

@ -139,7 +139,8 @@ describe("hx-on attribute", function() {
it("can handle event types with dots", function () { it("can handle event types with dots", function () {
var btn = make("<button hx-on='my.custom.event: window.foo = true'>Foo</button>"); var btn = make("<button hx-on='my.custom.event: window.foo = true'>Foo</button>");
btn.dispatchEvent(new CustomEvent('my.custom.event')); // IE11 doesn't support `new CustomEvent()` so call htmx' internal utility function
btn.dispatchEvent(htmx._("makeEvent")('my.custom.event'));
window.foo.should.equal(true); window.foo.should.equal(true);
delete window.foo; delete window.foo;
}); });

View File

@ -29,6 +29,11 @@ describe('Core htmx extension tests', function() {
onEvent: function(name, evt) { onEvent: function(name, evt) {
if (name === 'htmx:beforeRequest') { if (name === 'htmx:beforeRequest') {
evt.preventDefault(); evt.preventDefault();
if (IsIE11()) {
// IE11 doesn't set defaultPrevented to true on custom events it seems, so use a
// return false instead to cancel the event
return false
}
} }
} }
}); });

View File

@ -168,7 +168,7 @@
<script class="mocha-exec"> <script class="mocha-exec">
document.addEventListener("DOMContentLoaded", function () { document.addEventListener("DOMContentLoaded", function () {
mocha.setup({globals: ['$0', '$1', '$2', '$3', '$4', 'performance', 'requestAnimationFrame', 'cancelAnimationFrame']}); <!-- IE11 --> mocha.setup({globals: ['$0', '$1', '$2', '$3', '$4', 'performance', 'requestAnimationFrame', 'cancelAnimationFrame', 'confirm']}); <!-- IE11 -->
mocha.run(); mocha.run();
}) })
</script> </script>