Bot releases are visible (Hide)
naja
package now exports all event types and some other auxiliary types so that you can unleash full strictness onto your TypeScript codebase. (#408)Published by github-actions[bot] 3 months ago
UIHandler.submitForm()
helper method now accepts a submitter element as its first parameter, in addition to a form. However, the native form.requestSubmit()
method is the recommended way to manually dispatch form submissions to Naja in modern browsers.submit
events of forms. The interaction
event's element
property continues to refer to the submitter element when available.exports
field in package.jsonNaja continues to hold its compatibility promise of working correctly "in the latest versions of Chromium (Chrome and Edge), Firefox, and WebKit (Safari)."
With this release, Naja newly relies on APIs that might not be available in some older versions of these browsers. If you still need to support these, please check the compatibility and available polyfills for the SubmitEvent.submitter
property, and the submitter
parameter in FormData()
constructor.
Published by github-actions[bot] 6 months ago
processInteraction()
that allows developers to process any custom interactions through Naja, including dispatching the interaction
event. (#388)type="submit"
. (#397)Published by github-actions[bot] 8 months ago
Naja 3.0 is an evolutionary release and should not come with any breaking changes for the majority of users. The breaking changes are mostly expected to affect advanced users, and developers who build custom extensions on top of Naja.
That said, there have been some changes in the inner workings of the snippet cache that may alter the behaviour, so it is strongly recommended that you properly test your application against the 3.x release.
β¨ SnippetHandler supports asynchronous snippet update operations, such as using View Transitions API. (#383) You can now wrap snippet updates in transitions, and rely on Naja dispatching the afterUpdate
event only after the update has been completed.
SnippetHandler dispatches a new pendingUpdate
event. The event is dispatched right before the now asynchronous update is invoked, and only if the update has not been prevented in the beforeUpdate
event.
β οΈ BREAKING CHANGE: if you are using SnippetHandler.updateSnippet()
or SnippetHandler.updateSnippets()
method directly, please note that the method is now asynchronous and the DOM is guaranteed to be updated only after its returned promise resolves.
β οΈ BREAKING CHANGE: due to the asynchronicity, it is no longer guaranteed that all snippets have been updated by the time success
and complete
events are dispatched.
β¨ SnippetCache stores raw snippet content. (#368) This makes snippet restoration more deterministic for snippet update event listeners.
The afterUpdate
event is the preferred way to e.g. initialize third-party scripts and widgets. Previously, snippet cache wasn't populated until after updating the snippets, and thus snippets stored in the cache might already have contained these DOM modifications; as a result, the same afterUpdate
listener would receive different inputs in different scenarios: one pristine when updating from the server, and one already modified when restoring the snippet from cache during history navigation.
In Naja 3.0, snippets are cached in the original form whenever possible, so that afterUpdate
event listeners receive the same, unaltered input, regardless of where it comes from.
β οΈ BREAKING CHANGE: if you are implementing your own snippet update operation, it is now expected to be an object implementing a pair of methods:
updateElement(snippet: Element, content: string): void | Promise<void>
This method should just wrap the original, pre-3.0 snippet update operation: it updates the snippet
element with the content
received from the server. As per the previous section, the update can now be asynchronous.
updateIndex(currentContent: string, newContent: string): string
This method has been added to integrate with the enhanced snippet cache capabilities. It applies the newContent
received from the server onto the snippet's cached currentContent
, and returns the result. This method works entirely with the raw snippet contents, no DOM involved.
For example, the built-in replace
operation implements this method so that it returns newContent
, whereas the append
operation does return a concatenation of currentContent + newContent
.
Current snippet update operation implementations are backward-compatible, with updateIndex()
falling back to simply returning newContent
received from the server. It is recommended that you update your implementation to include the newly added method, so that you have full control over the implementation and its behaviour.
Published by github-actions[bot] 8 months ago
This is a release candidate of the upcoming Naja 3.0. This is an evolutionary release and should not come with any breaking changes for the majority of users. The breaking changes are mostly expected to affect advanced users, and developers who build custom extensions on top of Naja.
That said, there have been some changes in the inner workings of the snippet cache that may alter the behaviour, so it is strongly recommended that you properly test your application against the 3.x release, and report any issues.
β¨ SnippetHandler supports asynchronous snippet update operations, such as using View Transitions API. (#383) You can now wrap snippet updates in transitions, and rely on Naja dispatching the afterUpdate
event only after the update has been completed.
SnippetHandler dispatches a new pendingUpdate
event. The event is dispatched right before the now asynchronous update is invoked, and only if the update has not been prevented in the beforeUpdate
event.
β οΈ BREAKING CHANGE: if you are using SnippetHandler.updateSnippet()
or SnippetHandler.updateSnippets()
method directly, please note that the method is now asynchronous and the DOM is guaranteed to be updated only after its returned promise resolves.
β οΈ BREAKING CHANGE: due to the asynchronicity, it is no longer guaranteed that all snippets have been updated by the time success
and complete
events are dispatched.
β¨ SnippetCache stores raw snippet content. (#368) This makes snippet restoration more deterministic for snippet update event listeners.
The afterUpdate
event is the preferred way to e.g. initialize third-party scripts and widgets. Previously, snippet cache wasn't populated until after updating the snippets, and thus snippets stored in the cache might already have contained these DOM modifications; as a result, the same afterUpdate
listener would receive different inputs in different scenarios: one pristine when updating from the server, and one already modified when restoring the snippet from cache during history navigation.
In Naja 3.0, snippets are cached in the original form whenever possible, so that afterUpdate
event listeners receive the same, unaltered input, regardless of where it comes from.
β οΈ BREAKING CHANGE: if you are implementing your own snippet update operation, it is now expected to be an object implementing a pair of methods:
updateElement(snippet: Element, content: string): void | Promise<void>
This method should just wrap the original, pre-3.0 snippet update operation: it updates the snippet
element with the content
received from the server. As per the previous section, the update can now be asynchronous.
updateIndex(currentContent: string, newContent: string): string
This method has been added to integrate with the enhanced snippet cache capabilities. It applies the newContent
received from the server onto the snippet's cached currentContent
, and returns the result. This method works entirely with the raw snippet contents, no DOM involved.
For example, the built-in replace
operation implements this method so that it returns newContent
, whereas the append
operation does return a concatenation of currentContent + newContent
.
Current snippet update operation implementations are backward-compatible, with updateIndex()
falling back to simply returning newContent
received from the server. It is recommended that you update your implementation to include the newly added method, so that you have full control over the implementation and its behaviour.
Published by github-actions[bot] 11 months ago
afterUpdate
event.Full Changelog: https://github.com/naja-js/naja/compare/2.6.0...2.6.1
Published by github-actions[bot] 11 months ago
restoreState
event contains the direction
of the history navigation: a negative number representing going back in history, and a positive number for going forward.buildState
event contains the operation
, indicating whether the current state is being replaced, or a new state is being pushed. (#380)redirect
event provides the setUrl()
method, allowing developers to programmatically alter the target URL.afterUpdate
event, executing scripts only from snippets that have actually been updated.snippet
in updateSnippet()
has been relaxed to Element
. (#379)Full Changelog: https://github.com/naja-js/naja/compare/2.5.0...2.6.0
Published by github-actions[bot] about 1 year ago
π§ This is a beta release to show some changes that should be coming to Naja in near future. Please help me test these changes by installing the beta
tag of Naja:
npm install naja@beta
β¨ SnippetCache tries to cache the raw markup of snippets as returned from the server, prior to applying any afterUpdate
changes. (#368)
β¨ HistoryHandler now includes more information about the history state change: (#380)
buildState
event includes information about the performed operation (pushState or replaceState),restoreState
event includes information about the direction
of the user's navigation that triggered the popstate.Published by github-actions[bot] about 2 years ago
payload
event that is dispatched just before success
and allows you to configure options
for Naja's internal components based on the server response payload.interaction
event are now prepopulated with configured default options.Full changelog: https://github.com/naja-js/naja/compare/2.4.0...2.5.0
Published by github-actions[bot] over 2 years ago
async
event listeners.Full changelog: https://github.com/naja-js/naja/compare/2.3.0...2.4.0
Published by github-actions[bot] almost 3 years ago
Published by github-actions[bot] almost 3 years ago
Published by jiripudil almost 3 years ago
β¨ SnippetCache has been extracted into a separate component and the feature now has its own documentation page.
historyUiCache
option has been deprecated in favour of the new snippetCache
option.HistoryHandler.uiCache
flag has been deprecated in favour of the snippetCache
option. You can configure it via naja.initialize(defaultOptions)
.data-naja-history-no-cache
attribute has been deprecated in favour of data-naja-snippet-cache="off"
.snippetCache: 'session'
option.store
, fetch
and restore
, that allow you to tweak the caching behaviour or bypass it altogether.β¨ HistoryHandler exposes two new events, buildState
and restoreState
. These allow you to hook into the History API integration, and the SnippetCache is built on top of them.
β¨ ScriptLoader is now able to deduplicate loaded scripts by a unique identifier (suggested in #336). You can add a data-naja-script-id
attribute to the <script>
element inside a snippet. ScriptLoader will only load each identified script once, even if it repeatedly appears in multiple snippet responses.
data
into (#315).naja.initialize()
is no longer required to be called after the DOM is loaded, Naja makes sure of that internally where necessary.Accept: application/json
header (#314).Published by github-actions[bot] over 3 years ago
isUrlAllowed()
to support protocol-relative URLsPublished by github-actions[bot] over 3 years ago
data
(#254).Published by github-actions[bot] over 3 years ago
Published by github-actions[bot] almost 4 years ago
Published by github-actions[bot] almost 4 years ago
Published by github-actions[bot] almost 4 years ago
clickElement()
and submitForm()
now return the promise from the underlying request call (#177).naja.makeRequest()
now serializes simple POJO data
into query string for GET and HEAD requests (#178).Published by github-actions[bot] about 4 years ago
historyUiCache
setting from defaultOptions (#85)package.json
(#91, #92, thanks @dakur)