Releases: github/catalyst
v1.7.0
What's Changed
- Docs: surface required delimiters for Targets' and Actions' syntax patterns by @francisfuzz in #320
- Allow for objects to be passed to lazyDefine, avoiding repeat calls by @keithamus in #321
New Contributors
- @francisfuzz made their first contribution in #320
Full Changelog: v1.6.1...v1.7.0
v1.6.1
What's Changed
Mostly documentation changes, but also now lazyDefine
will observe @controller
shadowroots. It does not patch attachShadow
and so if you want it to observe non-catalyst controller shadowroots, you will need to do so manually:
import {observe} from '@github/catalyst/lib/lazy-define.js'
observe(shadowRoot)
- fix: better anchor colors from Primer primitives by @robin4a4 in #270
- Prev and next links by @robin4a4 in #272
- wrong urls for prev and next links by @robin4a4 in #274
- add provideAsync by @keithamus in #278
- upgrade all dependencies by @keithamus in #280
- Bump commonmarker from 0.23.4 to 0.23.6 in /docs by @dependabot in #282
- keep hidden items hidden in sidebar and prev/next by @keithamus in #286
- Separate v2 docs by @keithamus in #287
- fix urls for dropdown by @keithamus in #288
- merge v2 docs into guide-v2 by @keithamus in #289
- fix permalink for conventions v2 guide by @keithamus in #290
- tweak css sidebar to be responsive by @keithamus in #292
- Bump json5 from 1.0.1 to 1.0.2 by @dependabot in #299
- Bump ua-parser-js from 1.0.2 to 1.0.33 by @dependabot in #301
- Bump commonmarker from 0.23.6 to 0.23.7 in /docs by @dependabot in #302
- Bump http-cache-semantics from 4.1.0 to 4.1.1 by @dependabot in #304
- Bump cacheable-request and @lhci/cli by @dependabot in #306
- Make the sidebar scrollable above 768px by @rik in #305
- Observe shadow root on connected callback by @williammartin in #308
New Contributors
- @robin4a4 made their first contribution in #270
- @williammartin made their first contribution in #308
Full Changelog: v1.6.0...v1.6.1
v1.6.0
New Features
We've added a new lazyDefine
function, which allows for lazy loading of controllers. See more about lazyDefine in the guide.
What's Changed
- Make node resolve default in web test runner by @keithamus in #266
lazyDefine
components by @koddsson in #268- Fix image link and alt text by @koddsson in #269
Full Changelog: v1.5.0...v1.6.0
v1.5.0
This change lays a bunch of groundwork for 2.0, mostly for things which are not related to production code, so very little has changed from 1.4.2 to 1.5.0.
The key new feature here is a temporary feature to help migration to 2.0: @attr
by default comes with a data-
prefix, this is being dropped in 2.0, and 1.5.0 now observed a classes attrPrefix
static property (which defaults to data-
). To enable an easier migration to 2.0, you can use this to refactor your code and drop the data-
attr prefix:
class HelloWorldController extends HTMLElement {
static attrPrefix = '' // defaults to 'data-'
}
What's Changed
- clean up register tests, use register like decorator by @keithamus in #214
- Expand docs on minification options by @keithamus in #217
- Create guide page for Testing by @keithamus in #218
- improve type definition for custom element class/instance by @keithamus in #222
- Upgrade outdated packages by @keithamus in #223
- Improve docs around manual naming to avoid minifier mangling by @keithamus in #224
- Update target tests by @koddsson in #225
- Support dasherizing symbols by using their descriptions by @keithamus in #226
- add marks feature by @keithamus in #227
- Cherry-pick attr tests from
use-delegates
. by @koddsson in #228 - add createAbility by @keithamus in #229
- amend attr tests to use two word attrs by @keithamus in #230
- fix reference to lockfile by @koddsson in #231
- Fix up types in tests by @keithamus in #232
- rework tests for bind by @keithamus in #234
- improve documentation around method/getter/setter decorators by @keithamus in #235
- add initializer to marks by @keithamus in #236
- split out ability & controllable by @keithamus in #238
- Add providable ability by @keithamus in #241
- Fix typo in providable code sample by @steves in #242
- ability subclasses should retain original class name by @keithamus in #244
- add tag observer by @keithamus in #245
- Fix providable bugs by @keithamus in #243
- ensure marks default to configurable+enumerable by @keithamus in #246
- align jekyll versions to github pages by @keithamus in #237
- Upgrade actions runners by @keithamus in #247
- swap
@providable
decorator in docs by @keithamus in #248 - small doc tweaks by @keithamus in #249
- rename tag-observer exports by @keithamus in #253
- add createAbility docs by @keithamus in #254
- tweaks to create-ability docs by @keithamus in #256
- simplify abilities docs - link to expanded Create Ability docs by @keithamus in #258
- Bump jpeg-js from 0.4.3 to 0.4.4 by @dependabot in #264
- allow for customising prefix of @attr names by @keithamus in #265
New Contributors
Full Changelog: v1.4.2...v1.5.0
v2.0.0-alpha1
This is an early pre-release of Catalyst 2.0, released in order to test for bugs. You should not consider this production ready.
2.0 is a almost-from-the-ground-up rewrite of the core behaviours to make things a bit more consistent and also to allow for more flexibility throughout 2.0. We've also improved the ergonomics and usability of some of the features.
Features
There are many changes and subtle improvements, so we'd recommend sitting down with your favourite beverage and re-reading the guide (NOTE: for pre-releases you'll need to read the v2 branch source. Sorry). Here are some of our favourite new features though:
@attr
and@target
can now be setters, meaning you can trigger behaviour when they change.@attr
,@target
, and class names now all have consistent dasherized versions for within HTML.- The html literal versions of
@attr
drop thedata-
prefix for better ergonomics. - Actions and Targets can now listen to closed shadowroots.
- We've added a new system for Abilities. We'll be adding two new abilities in the 2.0 release:
@loadable
and@providable
. See the guide for more. - You can create your own abilities for shared functionality!
Breaking Changes
Here's a summary of breaking changes in order of "you'll definitely need to change this" down to "this probably wont effect you".
🔴 @attr
is no longer prefixed with data-
in HTML
The @attr
decorator used to dasherize a JS property name and then prefix it with data-
for use in HTML, so in other words @attr fooBar
in JS would result in data-foo-bar=
in HTML. This is now no longer the case, and instead @attr fooBar
will result in an HTML attribute name of foo-bar=
. We decided to do this as it is more ergonomic, and less surprising. @attr
names now work like class names: they get dasherized, no surprising prefixes.
What's the easiest fix?
The easiest way to handle this change is to prefix your JS properties with data
, so @attr fooBar
becomes @attr dataFooBar
. No changes will need to be made to your HTML, and if you reference the HTML value in your JS (e.g. hasAttribute('data-foo-bar')
) then this will also not need to change.
What's a better fix?
Drop the data-
prefix from your HTML attributes, as this will be more ergonomic. You might also need to drop the data-
prefix in any JS where you reference the literal HTML value in your JS (e.g. hasAttribute('data-foo-bar')
should be hasAttribute('foo-bar')
).
🔴 @attr
s must consist of 2 words (camelcased)
In order to drop the data-
prefix, we decided a good trade-off would be to require @attr
s to consist of 2 words - in other words the HTML attribute name must have a dash. Names like @attr foo
will need to be refactored to include 2 words (or one uppercase character), so for example @attr fooBar
is acceptable.
What's the easiest fix?
The easiest way to handle this change is to prefix your JS properties with data
which will also get around the dropping of the data
prefix, so @attr foo
becomes @attr dataFoo
. No changes will need to be made to your HTML, and if you reference the HTML value in your JS (e.g. hasAttribute('data-foo-bar')
) then this will also not need to change.
What's a better fix?
If you have @attr
properties that are one word, you'll need to think of a name for them that consists of two words. Here are some examples to give you some inspiration:
@attr path
->@attr pathName
@attr valid
->@attr isValid
@attr changed
->@attr hasChanged
@attr error
->@attr errorMessage
@attr src
->@attr srcURL
@attr content
->@attr contentText
@attr json
-> Literally anything else 😉.
🟡 @attr
no longer sets observedAttributes
, so attributeChangedCallback
won't be fired.
We've changed how @attr
updates its attributes, to use a mutationobserver under the hood - instead of attributeChangedCallback
. There are many reasons for this change; it was surprising to users to see attributeChangedCallback
being called for stuff that isn't in observedAttributes
, also attributeChangedCallback
didn't correctly coerce values - it's only called with string
types. With Catalyst 2.0 you can instead add @attr
to a setter, and have that respond to changes to the attribute.
What's the easiest fix?
If you don't have an attributeChangedCallback
in your code, forget about it. If you do, then the easiest fix is to manually add observedAttributes
to your class, to reflect all of the @attr
decorated fields. So e.g. @attr fooBar
would need static observedAttributes = ['foo-bar']
.
What's a better fix?
Refactor your attributeChangedCallback
to remove checks for your @attr
decorated attributes, and use setters instead. For example:
🟡 @attr
no longer sets the html in the connectedCallback
It was surprising to see attributes sprouting onto an element when it gets connected, and it isn't inline with how built-in elements behave. @attr
s now do not set the html attribute value based on the initial value, instead the the html attribute value is used to override the default property value. This works more like built-in HTML elements:
const input = document.createElement('input')
console.assert(input.type === 'text') // default value
console.assert(input.hasAttribute('type') === false) // no attribute to override
input.setAttribute('type', 'number')
console.assert(input.type === 'number') // overrides based on attribute
input.removeAttribute('type')
console.assert(input.type === 'text') // back to default value
What's the easiest fix?
You probably won't need to do anything. If your code depends on the html attribute existing during connectedCallback
, then a quick fix is to set the value to itself in your connectedCallback
. e.g. if you have an @attr fooBar = 'hello'
then in your connectedCallback
add the line this.fooBar = this.fooBar
.
What's a better fix?
If your code depends on the html attribute existing during connectedCallback
, then you should refactor your code. Strategies around this vary, but generally you should refer to the property name rather than the html literal value, alternatively if you still need to access the html literal value you can use a logical OR operator with the @attr
default value, for example for an @attr fooBar = 'hello'
you could use this.getAttribute('foo-bar') || 'hello'
.
🟡 @controller
s now will drop the Controller
/Element
/Component
suffix
We've had feedback that Element
is a fine suffix to drop, but it'd be nice to have symmetry with other frameworks and drop more suffixes - so in 2.0 we're also dropping Controller
and Component
suffixes. This means for an element named something like FooBarController
in 1.x would be <foo-bar-controller />
, it'll be <foo-bar />
in 2.x. Similarly FooBarComponent
will also be <foo-bar />
.
What's the easiest fix?
We audited all open source Catalyst components (and the closed source ones we had access to) and couldn't find any that end in Component
or Controller
, so we think it's really unlikely that this will be a problem.
Nevertheless, there's only one type of fix for this - and that's to drop the suffix from your HTML.
What's Changed
- clean up register tests, use register like decorator by @keithamus in #214
- Expand docs on minification options by @keithamus in #217
- Create guide page for Testing by @keithamus in #218
- improve type definition for custom element class/instance by @keithamus in #222
- Upgrade outdated packages by @keithamus in #223
- Improve docs around manual naming to avoid minifier mangling by @keithamus in #224
- Update target tests by @koddsson in #225
- Support dasherizing symbols by using their descriptions by @keithamus in #226
- add marks feature by @keithamus in #227
- Cherry-pick attr tests from
use-delegates
. by @koddsson in #228 - add createAbility by @keithamus in #229
- amend attr tests to use two word attrs by @keithamus in #230
- fix reference to lockfile by @koddsson in #231
- Fix up types in tests by @keithamus in #232
- rework tests for bind by @keithamus in #234
- improve documentation around method/getter/setter decorators by @keithamus in #235
- add initializer to marks by @keithamus in #236
- split out ability & controllable by @keithamus in #238
- Add providable ability by @keithamus in #241
- Fix typo in providable code sample by @steves in #242
- ability subclasses should retain original class name by @keithamus in #244
- add tag observer by @keithamus in #245
- Fix providable bugs by @keithamus in #243
- ensure marks default to configurable+enumerable by @keithamus in #246
- align jekyll versions to github pages by @keithamus in #237
- Upgrade ac...
v1.4.2
v1.4.1
v1.4.0
This release allows for safe custom element redefinition, which enables the use of HMR plugins with Catalyst controllers. Releases prior to this would first check if the element is already registered, and skip registration. Instead, in 1.4.0, elements will try to register and catch redefinition errors if they’re thrown - which means HMR plugins that override customElements.define
will now work.
v1.3.2
What's Changed
- chore(deps-dev): bump karma from 6.3.14 to 6.3.16 by @dependabot in #184
- chore(deps): bump ansi-regex from 3.0.0 to 3.0.1 by @dependabot in #192
- Return void from target decorators by @jdanyow in #195
Full Changelog: v1.3.1...v1.3.2
v1.3.1
What's Changed
- document debouncing without a library by @keithamus in #186
- document Abortcontroller with addEventListener by @keithamus in #185
- chore(deps): bump follow-redirects from 1.14.7 to 1.14.9 by @dependabot in #182
- Add a release action by @koddsson in #188
- Add note on AbortController reuse by @keithamus in #189
- Update eslint and friends by @keithamus in #190
- Initialize attrs on attributechangedcallback by @keithamus in #191
Full Changelog: v1.3.0...v1.3.1