Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/htmx.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,12 @@ return (function () {

/**
* @param {string} tag
* @param {boolean} global
* @param {boolean} [global]
* @returns {RegExp}
*/
function makeTagRegEx(tag, global = false) {
return new RegExp(`<${tag}(\\s[^>]*>|>)([\\s\\S]*?)<\\/${tag}>`,
global ? 'gim' : 'im');
function makeTagRegEx(tag, global) {
return new RegExp('<' + tag + '(\\s[^>]*>|>)([\\s\\S]*?)<\\/' + tag + '>',
!!global ? 'gim' : 'im')
}

function parseInterval(str) {
Expand Down Expand Up @@ -1945,6 +1945,9 @@ return (function () {

function shouldProcessHxOn(elt) {
var attributes = elt.attributes
if (!attributes) {
return false
}
for (var j = 0; j < attributes.length; j++) {
var attrName = attributes[j].name
if (startsWith(attrName, "hx-on:") || startsWith(attrName, "data-hx-on:") ||
Expand All @@ -1967,11 +1970,11 @@ return (function () {
var iter = document.evaluate('.//*[@*[ starts-with(name(), "hx-on:") or starts-with(name(), "data-hx-on:") or' +
' starts-with(name(), "hx-on-") or starts-with(name(), "data-hx-on-") ]]', elt)
while (node = iter.iterateNext()) elements.push(node)
} else {
} else if (typeof elt.getElementsByTagName === "function") {
var allElements = elt.getElementsByTagName("*")
for (var i = 0; i < allElements.length; i++) {
if (shouldProcessHxOn(allElements[i])) {
elements.push(allElements[i])
if (shouldProcessHxOn(allElements[i])) {
elements.push(allElements[i])
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions test/core/ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -1237,6 +1237,11 @@ describe("Core htmx AJAX Tests", function(){
})

it('properly handles inputs external to form', function () {
if (!supportsFormAttribute()) {
this._runnable.title += " - Skipped as IE11 doesn't support form attribute"
this.skip()
return
}
var values;
this.server.respondWith("Post", "/test", function (xhr) {
values = getParameters(xhr);
Expand Down Expand Up @@ -1287,6 +1292,11 @@ describe("Core htmx AJAX Tests", function(){
})

it("can associate submit buttons from outside a form with the current version of the form after swap", function(){
if (!supportsFormAttribute()) {
this._runnable.title += " - Skipped as IE11 doesn't support form attribute"
this.skip()
return
}
const template = '<form ' +
'id="hello" ' +
'hx-target="#hello" ' +
Expand Down
10 changes: 10 additions & 0 deletions test/core/regressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@ describe("Core htmx Regression Tests", function(){
})

it("script tags only execute once using templates", function(done) {
if (!supportsTemplates()) {
this._runnable.title += " - Skipped as IE11 doesn't support templates"
this.skip()
return
}
var oldUseTemplateFragmentsValue = htmx.config.useTemplateFragments
htmx.config.useTemplateFragments = true

Expand All @@ -267,6 +272,11 @@ describe("Core htmx Regression Tests", function(){
})

it("script tags only execute once when nested using templates", function(done) {
if (!supportsTemplates()) {
this._runnable.title += " - Skipped as IE11 doesn't support templates"
this.skip()
return
}
var oldUseTemplateFragmentsValue = htmx.config.useTemplateFragments
htmx.config.useTemplateFragments = true

Expand Down