Release 9.8.0
9.8.0 (2022-12-23)
Breaking Changes
-
pat-validation: Remove error-template option. (78c544b)
This is a breaking change.
Due to a Content-Security-Policy problem with dom.template when unsafe-eval
is not set - which you wouldn't set if possible - we had to remove the
error-template parameter. Instead the template is now defined in a
error_template
method on the Patten class and can be customized by
subclassing and extending the pat-validation pattern or by patching it via
Pattern.prototype.
Features
-
pat-sortable: Support initialization after injection. (afaf388)
-
core events: Add dragstart and dragend event factories. (73d7fc7)
-
pat-sortable: Initialize sorting on cloned elements. (d7abbc0)
Fix sorting behavior on cloned elements, which broke on Patternslib 9.8.0-alpha.0.
-
core basepattern: Add a destroy method. (f9ca65a)
The destroy method removes the pattern instance from the element.
This is necessary to re-initialize the same pattern on the same element. -
core events: Support await_pattern_init with pattern double registration attempt. (e8640a9)
When a pattern is tried to be initialized on the same element twice, throw
an event and use that event in await_pattern_init to reject the promise.
When using await_pattern_init you might want to try/catch the block to
handle any possible double-registration errors. -
core events: Support once-events in add_event_listener. (fc0e333)
Add support for once-events in add_event_listener and unregister them when
called from the event_listener_map. -
Build: Include the build in the npm package. (544b589)
The compiled build is now included in npm packages by including the dist
directory in .npmignore. To not increase the package size too much the
JavaScript map files are not included. Now you can include Patternslib by
using unpkg or jsDelivr like so:
https://unpkg.com/@patternslib/[email protected]/dist/bundle.min.js
or
https://cdn.jsdelivr.net/npm/@patternslib/[email protected]/dist/bundle.min.js
-
core dom: Add is_input method. (554e32e)
Add
is_input
to test if a element is of input type. This is basically the
same as$(":input")
from Sizzle/jQuery. -
pat-markdown: Soft-depend on pat-syntax-highlight. (cf0f6e3)
Only highlight code blocks when the pattern is available.
Not hard-depending and importing pat-syntax-highlight fixes a problem where
only including pat-markup also included pat-syntax-highlight and it's big
highlight.js library.This can reduce the generated bundle size significantly.
-
pat-tooltip: Soft-depend on pat-markdown. (1f81238)
Only register the markdown data type handler when the pattern is available.
Not hard-depending and importing pat-markdown fixes a problem where only
including pat-tooltip also included pat-markdown and pat-syntax-highlight
with it's big highlight.js library.This can reduce the generated bundle size significantly.
-
core basepattern: Provide the parser as static attribute. (49db677)
This change is backwards compatible Change the parser attribute to a static
attribute and provide it also on the object. This change was necessary
because pat-inject was using the parser on a registered Pattern class to
rebase URL configurations in the rebaseHTML method. There was no access to
the parser attribute on non-instatiated objects before, now it is. -
pat-autosuggest: Add a configurable separator for multiple values. (21cbe8f)
Bug Fixes
-
pat-sortable: Initialize already existing sortable handles. (b3f5077)
Also allow the sortable itself to be the handle.
-
pat-sortable: Show dragable item image while dragging. (1c9eb80)
-
pat-sortable: sortable-handle needs to be injected at last element of the sortable item. (db02541)
-
Build: Load modernizr early and non-asynchronously. (8bc9b66)
Include the modernizr bundle by injecting a script tag. This ensures
modernizr is loaded synchronously and executing early and sets it's feature
detection classes before the layout is done by the browser.You can disable loading of modernizr by setting the following before the
<script>window.__patternslib_disable_modernizr = true;</script>
Patternslib bundle.min.js is included:Also, the "js" class is set on the HTML root tag when a "no-js" class was
present regardless of the__patternslib_disable_modernizr
setting.Since Patternslib 9.0.0-alpha.0 where we introduced webpack module
federation for our bundles, Modernizr is loaded asynchronously and applying
it's CSS classes a tick too late. For example, the change from the "no-js"
to the "js" class was done while the tiles have already been drawn and
visible on the screen, resulting in screen flickering. There are a number
of projects which depend on Modernizr being applied early. -
Build: Separate modernizr into a own bundle. (875b041)
-
Build: Also include necessary
_sass
directory in the npm package. (70da6b1) -
Build: Also include the webpack configs in the npm package. (f6bf2bf)
Previous packages depending on @patternslib/patternslib also extended
Patternslib' webpack configs. Include these configs for backwards
compatibility. -
pat-bumper: Remove style import from the patterns SCSS file. (094010b)
-
pat-tooltip: Cleanup tooltip after it's destroyed. (ac27e20)
When the tooltip is destroyed, also call the tooltip's BasePattern destroy
method to clean up and release the tooltip from the element. After that it
can be instantiated on the same element again. This change was necessary
after the recent BasePattern change. -
pat-validation: Make sure to cancel submit events on invalid forms. (e218af2)
Make sure that submit events are canceled on invalid forms by using a
capturing event handler which is invoked before non-capturing events.The previous commit exposed a problem with the submit event handling, where
the then non-capturing submit event handler was registered later than the
one from pat-inject because pat-validation's async init method where
pat-inject's init method is yet non-async. That happened even the
pat-validation's pattern initialization is enforced to run first due to
registration reordering in the Pattern registry. Now with the capturing
event handler this problem is fixed. -
Build: Fix tiptap error. (6e67655)
Fix tiptap "Unhandled Promise Rejection" error due to multiple versions of
a tiptap dependency installed. Removing yarn.lock in re-installing solves
this. -
pat-clone-code: Fix a Content-Security-Policy problem. (e38f987)
Do not use dom.template for the wrapper template to not get caught by the
browser's Content-Security-Policy. If set, a unsafe-eval error would be
thrown and the pattern refuse to run. -
pat-bumper: Fix runtime error due to reference to wrong container. (893d392)
-
pat-collapsible: Class-based patterns cannot be jQuery plugins. (eedcc47)
-
pat-syntax-highlight: Do not load all languages. (c34d4a0)
Change the import so that no language is included by default. Instead
import the languages dynamically.This reduces the download size when pat-syntaax-highlight is used
significantly. -
pat-syntax-highlight: Fix language registration. (19bbb53)
Fix a typo where all languages were registered as "javascript".
-
pat-bumper: Do not calculate padding/margin on viewport. (baae37c)
On the viewport as scrolling container paddings and margins are not
influencing the sticky element's position. This is contrary to other
scrolling containers within the document. The position calculation is
easier and only consists of the clientWidth/Height to respect scrollbar
widths. -
pat-bumper: Fix position calculation for sticky elements. (4da8d70)
Following the sticky position specification only top, right, bottom and
left values are used to compute the position relative to the scrolling
container. -
pat-bumper: Support dynamic position values. (b70fad2)
The container and element positions need to be calculated every time, as
they are likely to be changed by dynamically assigned classes. This can be
the case for different position values based on the scrolling direction
classes set by pat-scroll-box. -
pat-auto-suggest: Adapt to changes from pat-depends where the event is called on the pat-depends element itself. (926de33)
-
pat-autofocus: Refocus on DOM updates by other Patterns. (4dc2963), closes #1092
Set the focus if appropriate when the DOM has changed and a pat-update
event has thrown. Please note, this does not use an IntersectionObserver
but relies on other Patterns using the pat-update event. This behavior
got lost in Patternslib 6.1 and is now restored.Fixes: #1092 -
pat-bumper: Correctly set the bumpuing classes. (e66b987), closes #1083
The bumping classes are now set correctly on any bumping direction.
The logic is adapted to work with any top, right, bottom, left, margin,
border and padding setting on a wrapping container, two different
containers for x and y scrolling and on the window viewport as
container.Fixes: #1083 -
pat-scroll-box: Fix failing tests due to timing inconsitencies. (7a03ef8)
Maintenance
-
Build: Upgrade dependencies. (befb845)
-
Build: Do not include the example minimalpattern in the build. (9712019)
-
Build: Remove now unused globals module. (8e05515)
jQuery is now imported and set earlier.
-
Docs: Update some documentation. (4ccf1bd)
-
pat-sortable: Modernize tests. (bf25dc4)
-
Build: Directly build the modernizr bundle. (ee2acdc)
Do not use an webpack entry to build the modernizr bundle with an webpack
runtime overhead. Instead, build it directly but abusing the webpack
CopyPlugin transform mechanism. We could also build the modernizr bundle
from the Makefile but that wouldn't provide the file when watching or when
running webpack-dev-server. -
Build: Optimize modernizr configuration. (e1fd8de)
Remove unnecessary tests in .modernizrrc.js and slim down the build size.
-
Upgrade dependencies. Also Upgrade to jQuery 3.6.2. (071e084)
-
core basepattern: Use identity instead equality comaprison instead in tests for stricter testing. (ce962d2)
-
Exclude more files from npm packages. (c312b96)
-
Only include dist/ and src/ directories in the npm package. (babc4b6)
-
pat-validation: Change to class based pattern. (11543ea)
This is needed for better customization in deriving projects.
-
Upgrade dependencies. (399105f)
-
Use browserslist defaults. (8867fd8)
-
Build: Upgrade dependencies. (fed2716)
-
core dom template: Warn about using dom.template due to a CSR probmel. (989fa9f)
Warn about a problem of dom.template with a Content-Security-Policy set. If
a CSR rule is set then dom.template would break the code unless
'unsafe-eval' is allowed (which you wouldn't normally allow when using a
CSR). Therefore it is not recommended to use this template function. -
pat-clone-code: Better example, correct documentation. (028ba07)
-
Remove IE related code paths. (9de0d95)
-
Add deprecation note for public_path. (f6d8124)
-
Build: Remove the IE11 polyfills-loader. (6eaddec)
Clear out the polyfills-loader script but keep the module for backwards
compatibility. No IE11 compatibility polyfills are included anymore as
support for IE11 has recently really and finally dropped. The
polyfills-loader.js file is still shipped but empty for compatibility with
projects including the polyfills loader. -
Build: Remove unused prismljs and google-code-prettify modules. (ed808e5)
-
Build: Update browserslist setting. (a29b9e8)
Explicitly remove ie11 from browserslist. It wasn't used due to the "not
dead" setting anyways. -
Build: Upgrade @patternslib/dev. (ed8d13a)
-
Build: Upgrade pat-tiptap to 4.7.0. (ad0be10)
-
core basepattern: Avoid code linting problem. (d2836bd)
Avoid code linting problem and make clear the init method is/can be
asynchronous. -
pat-markdown: Improve registering the markdown handler for pat-inject. (3f17e99)
Wait a tick before registering the markdown type handler for pat-inject.
With that there is no need for pat-inject to be imported before
pat-markdown, as long as it is imported side by side with pat-markdown. -
pat-markdown: Switch to class based pattern. (c6dc8b0)
-
pat-stacks: The trigger should be a static property. (4f0bb0f)
-
pat-syntax-highlight: The trigger should be a static property. (e341681)
-
pat-tooltip: Switch to class based pattern. (4fdb12a)
-
Build: Upgrade dependencies. (5e5b54d)
-
pat-autofocus: Fix sporadic autofocus test failures. (9c13c56)
-
core utils: utils.hideOrShow: add updated dom to pat-update event data. (0b5f92f)
-
pat stacks: Modernize code. (7928880)
-
pat-autofocus: Switch to class based patterns. (4302d6c)
-
pat-bumper: Correct documentation. (fa0254c)
-
pat-bumper: No IE11 support anymore. (bae3f55)
-
pat-bumper: Switch to class based patterns. (2b04cbc)
-
pat-clone-code: Make parser attribute a static attribute. (eb70b84)
-
pat-clone: Add updated dom to pat-update event data. (18375fe), closes #1092
Related: #1092
-
pat-clone: Modernize code. (f0d8d5b)
-
pat-collapsible: Add updated dom to pat-update event data. (fde478c), closes #1092
Related: #1092
-
pat-collapsible: Modernize code. (870f6dc)
-
pat-collapsible: Switch to class based pattern. (417b0d6)
-
pat-depends: Always throw update event and add changed dom structure. (6152afd), closes #1092
Trigger pat-update on pat-depends itself and add updated dom structure to
pat-update event data. This allows other patterns to also listen to changes
in pat-depends. Goes together with the previous change on
pat-autofocus.Related: #1092
-
pat-equaliser: Add updated dom to pat-update event data. (c66a431)
-
pat-scroll: Add updated dom to pat-update event data. (fc23966)
-
pat-scroll: Code cleanup. (4f27b99)
-
pat-scroll: Fix test markup. (9b788a0)
-
pat-sortable: Add updated dom to pat-update event data. (18711eb)
-
pat-stacks: Add updated dom to pat-update event data. (41f8bb3)
-
pat-stacks: Switch to class based pattern. (6065eae)
-
pat-switch: Add updated dom to pat-update event data. (7434236)
-
pat-toggle: Add updated dom to pat-update event data. (56a0073)