642 Commits

Author SHA1 Message Date
Vincent
23d473291d
Updated mocha, tests now work with node 20 (#2122)
* Updated mocha, tests now work with node 20

* Update package-lock.json

* Enable Node CI for v2.0v2.0 branch (#2123)

Run tests for v2.0v2.0 branch too

* Bump CI's node version to 20.x
2023-12-21 16:54:02 -05:00
Vincent
b9da68d970
Support encapsulating oob swap elements in templates in response (#2120) 2023-12-21 12:39:23 -07:00
Alexander Petros
f4f35aec76 Format the rest of tests 2023-12-21 13:26:41 -05:00
Alexander Petros
290a78f6b0 Fix delete statement in two tests 2023-12-21 13:25:46 -05:00
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
Carson Gross
b4080e71da remove psychotic test 2023-12-20 15:48:31 -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
Fernando Comunello
e9bce8db65
Improve head tag parsing on template fragments (#2024)
Fix https://github.com/bigskysoftware/htmx/issues/2018
2023-12-20 15:37:42 -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
Denis Palashevskii
23256373fc
Remove legacy WS/SSE code (#2095)
* apply updated patch with legacy WS/SSE removal

* remove legace WS/SSE from the test server also

* remove sse mention from getTriggerSpec()

* clean up sse.js implementation after removal of hx-sse
2023-12-14 15:54:16 -07:00
Carson Gross
0eb8190342 Merge branch 'dev' into v2.0v2.0 2023-12-14 14:34:29 -07:00
fhp-mec
11cef8ee83
Fix: Make the SSE extension work properly and adhere to tests (#2025)
* Process sse-swap properly when swapped in

Previously `sse-swap` were only processed when `sse-connect` was on the
root of what was being swapped in.
This is now fixed so that the closest sseEventSource is found and used as the
event source

* Pass for code readabiltiy

remove the nested if statements as there is no difference in handling
between sseURL and LegacySSEUrl.

* Fix indenting

* Initial attempt at sse extension tests

* Make existing tests pass

* Add test case for #916

* backport test for #916 to hx-sse for completeness

* add a distinct test for sse-swap

* more tests, fix tests

+ more tests differentiating the implementation of sse-swap and
hx-trigger
* fix for "is closed after removal with no close and activity"

* Cleanup listener if element is gone

* Revert "Cleanup listener if element is gone"

This reverts commit bbe3715276302656d1a422fbc4778842776e35f6.

* Clean up listeners if element gone, fix indenting

* Incorportate feedback from first review

+ seperate eventSource creation logic and event registering logic
+ manually create event handling, still confused by how hx-trigger works
* `createEventSourceOnElement` now looks for event sources in children
* explicitly handle legacy sse handling instead of having extra
  selectors in `querySelectorOnThisOrChildren`
+ a few readability changes
+ add regression check to make sure that sseEventSource is only created
  on elements with sse-connect or equivalent
+ add test to make sure that sse-connect in the child of a swapped
  element is handled

* Allow multiple listeners in eventsource mock

* Backport eventsource mocks to legacy tests

---------

Co-authored-by: 1cg <469183+1cg@users.noreply.github.com>
2023-12-14 14:33:38 -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
Vincent
4057f9c465
Trigger specs cache indentation fix + documentation & tests (#2094)
* Fix parseAndCacheTrigger indentation as discussed in #1540

https://github.com/bigskysoftware/htmx/pull/1540#issuecomment-1834651800

* Trigger specs cache documentation + tests
2023-12-14 11:44:11 -07:00
Jyri-Matti Lähteenmäki
7866258936
add extension to populate path variables with request parameters (#1307)
* add extension to populate path variables with request parameters

* update extension readme
2023-12-13 18:31:28 -07:00
Carson Gross
ad871a9576 Merge branch 'v2.0v2.0' into disable-inheritance
# Conflicts:
#	src/htmx.js
2023-12-13 17:08:52 -07:00
Carson Gross
cd176d61d7 remove legacy hx-on= syntax 2023-12-13 14:59:48 -07:00
Carson Gross
22fde35674 Merge branch 'dev' into v2.0v2.0 2023-12-13 14:46:37 -07:00
Carson Gross
3be4202e5e add support for dashes in hx-on* attributes 2023-12-07 15:15:10 -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
Dan Palmer
0b37d0507d
Fix relative resource URLs for boosted links (#1960)
Fix relative URLs
2023-11-19 07:56:06 -07:00
matiboy
c454ea4eee
Fix WS sendImmediately (#1949)
* Tests at current state of the code

* Currently failing case (actual issue)

* Fix issue

---------

Co-authored-by: mat <matt@techspace.asia>
2023-11-16 13:48:36 -07:00
Jonathan Rietveld
7ef95e8963
Allow CSS selectors with whitespace in hx-trigger (#1913)
* Allow CSS selectors with whitespace in `hx-trigger`

Parsing of `hx-trigger` scans for whitespace, so if a CSS selector is used that contains whitespace, e.g. `form input`, a syntax error is raised.
A workaround is implemented by allowing such a CSS selector to be wrapped in either curly braces or parentheses.

* Add explanation whitespace in CSS selector to docs

* Tests for CSS selectors containing whitespace

* Use faster RegEx test, remove redundant variable declarations

* Added Descendant Combinator support to `root` and `target` modifiers

* Add missing semicolon

* Tests for descendant combinators in `root` and `target` modifiers

* Improve descendant combinator test coverage
2023-11-16 13:45:46 -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
69c053c136 initial inheritance disabling work 2023-11-14 16:27:49 -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
Alexander Petros
2c2bf5679f
Remove type:module from package.json (#1968) 2023-11-06 19:00:37 +01:00
Vincent
8ddd079b90
IE11 compatibility fixes (#1948) 2023-11-02 16:40:33 -06:00
Carson Gross
5cd5f927ba Merge branch 'master' into dev 2023-11-02 15:12:37 -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
Raphaël Piccolin
fdd2570ac8
fix: prevent nodeData.onHandlers overwrite (#1894)
* fix: prevent nodeData.onHandlers() overwrite

* fix: improved type safety

* test: hx-on handler cleanup

* style: wording

* chore: extra line
2023-10-26 14:45:46 -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
Denis Palashevskii
a679244c40
Fix websocket polling trigger (#1903)
fix websocket polling trigger
2023-10-26 11:54:24 -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
Alexander Petros
a66a98b9ed
Fix WS/SSE tests and replace go backend with NodeJS (#1876)
* Write WS and SSE test backend in node

* Refactor pages so that the URLs work

* Add tab highlighting script

* Fix stream with multiple events

* Fix highlighting on ext links

* Refactor WS code

* Support event trigger tests

* Add some jitter to the intervals

* Delete old go backend

* Update README with new info and credits

* Update top-level README

* Move ws to dev dependencies

* Remove extraneous go server

* Fix misplace comment
2023-10-12 15:54:40 -05:00
Vincent
7274454360
[New feature] selector-less next and previous targets (#1478)
* nextElementSibling and previousElementSibling target selectors

* Renamed nextElementSibling => next, previousElementSibling => previous
2023-10-06 22:25:03 -06:00
André Rouél
76e0ca1216
Fix Handlebars template rendering (#1836)
Fix Handlebars template rendering (see #801 and #1801)

Co-authored-by: russ4stall <russ@slashpine.tech>
2023-10-06 22:04:58 -06:00
Sam Dudley
355a4fad65
Ignore formmethod when value is "dialog" (#1867)
Fixes #1866
2023-10-06 22:04:02 -06:00
Carson Gross
a5fd1b7081 make singular to make more consistent w/ other attributes 2023-09-21 16:57:28 -06:00
Carson Gross
aa7ae144b5 Merge branch 'master' into dev 2023-09-21 15:48:07 -06:00