247 Commits

Author SHA1 Message Date
Alexander Petros
4b890ce72d Run linter on the tests too 2023-12-21 13:22:10 -05:00
Carson Gross
41e9ce3593 Merge branch 'dev' into v2.0v2.0 2023-12-20 15:48:47 -07:00
Thomas Cowart
078d5da5b4
Update parseInterval to handle "0" correctly (#1835)
* Update parseInterval to handle "0" correctly

When a parameter like "0ms" is passed in to parseInterval it gets parsed to 0.
Previously this would result in a return value of "undefined" because 0 is falsy
and thus the `return 0 || undefined` statements return undefined.

The purpose of the form `parseFloat(str) || undefined` was to return "undefined" if
parseFloat failed (parseFloat returns NaN, a falsy value, if it can't parse its
argument). Unfortunately, as mentioned, parseFloat can also succeed and return a
falsy value -- when the argument is "0" (or "0.0", etc.). So the new code, rather
than depending on the falsiness of the result of parseFloat, explicitly checks for
a NaN.

* Adds some semicolons

Adds some semicolons to parseInterval (and tests) for consistency.

* Add one more parseInterval test for "0"

Adds test test to make sure parseInterval works on "0".

* Adds functional tests for every, swap, settle, throttle, and delay

* Explcitly check that setTimeout values are > 0

These values come from user settings that are read from parseInterval,
so they could be a number or undefined.

If the value being checked is > 0 setTimeout will be called with some
associated function. If the value is 0 or 'undefined' the associated function
will be called immediately ('undefined' is not greater than 0).

* Change '!== undefined' to '> 0'

`pollInterval !== undefined` is a subtly different conditional than just `pollInterval` or `pollInterval > 0` (which are equivalent). Changes the conditional to `pollInterval > 0` so as to not change the behavior but also be more explicit in the test.
2023-12-20 15:46:04 -07:00
Carson Gross
46a1502a84 fix the shadow root tests interfering w/ other tests 2023-12-20 13:45:13 -07:00
Carson Gross
7c1c406efc Merge branch 'v2.0v2.0' into merge-2075
# Conflicts:
#	src/htmx.js
2023-12-20 13:22:49 -07:00
Carson Gross
b9dbbf52ca Merge branch 'v2.0v2.0' into config-return-behavor
# Conflicts:
#	src/htmx.js
2023-12-14 11:59:14 -07:00
Carson Gross
22fde35674 Merge branch 'dev' into v2.0v2.0 2023-12-13 14:46:37 -07:00
Katrina Scialdone
edc31073a7 Add tests for new extended selector syntax 2023-12-07 08:58:28 -07:00
Katrina Scialdone
4d9adabe6c Make shadow DOM tests actually pass 2023-12-07 08:48:20 -07:00
Katrina Scialdone
5f92e2cc92 Add shadow DOM tests 2023-12-07 08:07:00 -07:00
flixcor
4dc97a400f
Exclude form elements within disabled fieldsets (#2012)
* Exclude form elements within disabled fieldsets

* add test for disabled fieldsets

* cleanup
2023-11-30 15:18:16 -07:00
Sascha Woo
b89e4f4bf6
HX-Request and HX-Current-URL headers are missing in the request to restore from history (#2013) 2023-11-30 15:17:39 -07:00
Vincent
200c503f31
Removed IE-specific tests (#2039) 2023-11-24 11:30:11 -05:00
Carson Gross
5c42b3442b flip defaults for 2.0 2023-11-21 14:57:52 -07:00
gbourant
6a9a861ad9
Allow user to override Content-Type header (#1906)
* allow user to override Content-Type header

* reorder the code so it won't use userSetContentType variable

* remove userSetContentType

* clarification

* remove unrelated changes

---------

Co-authored-by: gbourant <root@gbourant.com>
2023-11-16 13:42:45 -07:00
Jacob Scott
cabff5db14
Add select option to htmx.ajax() (#1985)
adds select to ajax api
2023-11-16 13:37:38 -07:00
Carson Gross
3287445049 make response handling configurable 2023-11-14 14:03:14 -07:00
RBRi
31908e4839
Add missing '})' in core ajax tests (#1998) 2023-11-14 15:27:50 -05:00
Vincent
8ddd079b90
IE11 compatibility fixes (#1948) 2023-11-02 16:40:33 -06:00
Eric Kwoka
bdcb040a2f
Fix stale form references (#1820)
* 🐛 ensures form reference is accurate

*  Adds test

* 🐛 Fixes null checks

* Revert www updates

This reverts commit d2d14056e2635688fdcb0e6abe572034f77c0bef.

* Revert www updates

This reverts commit 3de585e02997a7877f47ef84f6c2f1a5fcc91ac3.

* ♻️ Refactors code

*  Passes tests
2023-10-31 16:32:58 -06:00
matiboy
712ee759f1
Fix confirmed being ignored in htmx:confirm event (#1610)
* Current behavior testing

Testing current library behavior

* Test should remove correct handler

* Add question in htmx:confirm event detail

* Allow skipping window.confirm

* Additional test without hx-confirm value

* Wrap htmx.off in finally

* More correct assertion in case of no calls to confirm

* Remove erroneously added formatting

* Remove erroneously added formatting

* Documentation, fix loop

---------

Co-authored-by: mat <matt@techspace.asia>
2023-10-26 14:43:41 -06:00
EliasPrescott
0718daa3ac
Fix: form submission of email inputs with multiple attribute (#1917)
fixing multiple email input values
2023-10-26 11:53:58 -06:00
Sam Dudley
355a4fad65
Ignore formmethod when value is "dialog" (#1867)
Fixes #1866
2023-10-06 22:04:02 -06:00
Sascha Woo
32b58c41cb
Add support for event cancellation (preventDefault) in extensions (#1456)
ext: add support for event cancellation via preventDefault()
2023-09-21 15:44:42 -06:00
Vincent
bb5413dfd2
[Tests] Fix test pipeline timing issues (#1818)
Fix test pipeline timing issues
2023-09-21 15:43:49 -06:00
Vincent
1f55266c47
[Test] Add a test to ensure inputs outside form with form attribute work properly (#1815)
Add a test to ensure inputs external to form work properly
2023-09-21 12:08:51 -06:00
Vincent
55c30b5607
Make htmx IE11 compatible again + tests IE11 compatible (#1687)
* Make htmx IE11 compatible again + tests IE11 compatible

* IE11 compatible handmade socket mock for ws-ext tests

* Fallback when xpath isn't supported, hx-on wildcard now working on IE11

* Merge remote-tracking branch 'upstream/relative-url-in-hx-boost' into ie11-compatibility
2023-09-06 09:55:18 -06:00
Alexander Petros
bfd7965dec
Disable logAll in headless mode (#1673)
Enabling logAll in just one test has the capacity to overwhelm the CI
with log output, so we disable it if the webdriver is automated.
2023-08-06 18:06:17 -06:00
Alexander Petros
c126d90588
Move load tests to the bottom of the core file (#1677)
This "resolves" a timing bug that was ocurring in the CI, where these
tests would run before htmx was loaded (only in the GitHub actions
servers). Not proud of this as a fix but I would like the CI to work
again ASAP.
2023-08-05 16:15:49 -06:00
Carson Gross
295d9f83eb remove a logAll() 2023-08-04 17:05:42 -06:00
Carson Gross
14e2a8c611 Merge remote-tracking branch 'origin/dev' into dev 2023-08-04 14:59:19 -06:00
Carson Gross
1acbbe5057 add test to ensure I don't screw up the sameHost value 2023-08-04 14:59:10 -06:00
Alexander Petros
fc4723c95f
Remove logAll from tests (#1657) 2023-08-01 18:04:44 -05:00
Carson Gross
36e6a426f9 security improvement
- add the `htmx.config.allowScriptTags` option
2023-07-31 12:12:44 -06:00
Carson Gross
19cb15caef security improvements
- add the `htmx.config.selfRequestsOnly` option
- add the `htmx:validateUrl` event
- better security documentation (incomplete, need to finish CORS)
2023-07-31 11:31:42 -06:00
Vincent
88a57cbc39
[Bugfix] Fix submit buttons/inputs handling (#1559)
* Fix submit buttons/inputs handling

* Removed useless concatenation

* Don't initNode links and forms that shouldn't be initialized

* Removed selectors filtering to alleviate PR

* Add @1cg 's addValueToValues function to factor code

* Use formValues variable for clicked button's value including
2023-07-25 12:55:22 -06:00
Vincent
91d06309dc
[New feature] Comma separated list syntax for HX-Trigger response header (#1479)
* Comma separated list syntax for HX-Trigger response header

* Fix wording
2023-07-18 13:10:43 -06:00
Vincent
e89c9c6402
[Bugfix] Handle dynamically added hx-disable (#1567)
Handle dynamically added hx-disable, clean up element #1176
2023-07-18 10:12:28 -06:00
Viktor Szépe
b085d89459
Fix assorted comment typos (#1590) 2023-07-17 11:36:04 -04:00
Carson Gross
1837f1fa97 Merge remote-tracking branch 'origin/master' into dev 2023-07-14 14:26:48 -06:00
RoToRa
3521c3c059
Implementation of HX-Reselect (#1385)
* HX-Reselect #1040

* HX-Reselect documentation

* HX-Reselect: Fix wrong variable name
2023-07-14 15:21:21 -05:00
Alexander Petros
febfa1c6a7
Add configs to choose between ecoding parameters in the URL or request body (#1525)
* Allow extensions to set request bodies for GET and DELETE

Even though the semantics of request bodies for GET and DELETE are
undefined, it is legal to set request bodies for them. By default, GET
and DELETE form parameters should be encoded as URLs. If, however, an
extension defines `encodeParameters`, that should override the default
and set the request bodies for GET and DELETE methods, just like it does
for all the other HTTP methods.

* Don't use URL params by default with DELETE

* Re-enable skipped DELETE test

* Remove reference to DELETE in comment

* Add "useUrlParams" to requestConfig

* Add config.methodsThatUseUrlParams

* Add methodsThatUseUrlParams config tests

* Don't switch to body params based on extension
2023-07-10 15:52:01 -06:00
Alexander Petros
fe4a803e2e
Add logNone function and apply it to tests (#1504)
New function to turn off the logger after using `logAll()`. I applied to
this to the tests as well so that `logAll()` is only used in the specfic
places where debug output is required. This makes the console output of
the tests dramatically more useful when run from the command line.
2023-06-24 14:21:55 -06:00
Denis Palashevskii
c8568ea774
fix a bug with afterSettle event raised just once after multiple OOB swaps (#1474) 2023-06-07 15:00:25 -06:00
Nicolas Appriou
1e1b7cf94a
escape colons in querySelector (#1314)
thank you!
2023-04-01 17:36:15 -06:00
Carson Gross
b4e6c5cbd5 hx-on attribute 2023-03-31 06:44:01 -06:00
Carson Gross
f84029badb fix https://github.com/bigskysoftware/htmx/issues/1264
update target to result of `beforeSwap` event
2023-02-24 11:01:53 -07:00
Carson Gross
704739d1f0 fix https://github.com/bigskysoftware/htmx/issues/1236
handle single quotes in ids properly by escaping them in selectors
2023-02-16 11:11:50 -07:00
Carson Gross
666c6aa8e5 support clicking on elements within a button element as well as directly on the element itself.
based on https://github.com/bigskysoftware/htmx/pull/1168
2023-01-06 14:18:00 -07:00
Ben Beecher
546fba2776
Hotfix for swapping fields that don't support setSelectionRange (#1187)
* Hotfix for swapping fields that don't support setSelectionRange

* Fix test
2023-01-04 08:54:38 -07:00