diff --git a/CHANGELOG.md b/CHANGELOG.md index f1877ad..b1d7ca8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,42 +8,53 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- You can now bind attributes with `??foo="${bar}"` syntax. This is functionally - equivalent to the `nullish` updater and will replace that functionality later. -- A new `unsafe` updater was added to replace `unsafeHTML` and `unsafeSVG`. You - use it like `unsafe(value, 'html')` and `unsafe(value, 'svg')`. +- You can now bind attributes with `??foo="${bar}"` syntax in the default + template engine. This is functionally equivalent to the `nullish` updater from + the default template engine and will replace that functionality later (#204). ### Changed - Template errors now include approximate line numbers from the offending - template. They also print the registered custom element tag name (#201). + template in the default template engine. They also print the registered custom + element tag name (#201). - The `ifDefined` updater now deletes the attribute on `null` in addition to - `undefined`. This makes it behave identically to `nullish`. However, both - updaters are deprecated and the `??attr` binding should be used instead. -- Interpolation of `textarea` is stricter. This used to be handled with some - leniency — ``. Now, you have to fit the - interpolation exactly — ``. + `undefined` in the default template engine. This makes it behave identically + to `nullish` in the default template engine. However, both updaters are + deprecated — the `??attr` binding should be used instead when using the + default template engine (#204). +- Interpolation of `textarea` is more strict in the default template engine. + This used to be handled with some leniency for newlines in templates — + ``. Now, you have to interpolate exactly — + `` (#219). +- You may now bind values of type `DocumentFragment` within the template engine. + In particular, this was added to enable advanced flows without needing to + bloat the default template engine interface (#207, #216). ### Deprecated - The `ifDefined` and `nullish` updaters are deprecated, update templates to use - syntax like `??foo="${bar}"`. -- The `repeat` updater is deprecated, use `map` instead. -- The `unsafeHTML` and `unsafeSVG` updaters are deprecated, use `unsafe`. + syntax like `??foo="${bar}"` (#204). +- The `repeat` updater is deprecated, use `map` instead (#204). +- The `unsafeHTML` and `unsafeSVG` updaters are deprecated, bind a + `DocumentFragment` value instead (#207, #216). - The `plaintext` tag is no longer handled. This is a deprecated html tag which - required special handling… but it’s unlikely that anyone is using that. + required special handling… but it’s unlikely that anyone is using that (#220). +- The `live` updater is deprecated. Use a delegated event listener for the + `change` event if you need tight control over DOM state in forms (#208). ### Fixed -- Transitions from different content values should all now work. For example, - you previously could not change from a text value to an array. Additionally, - state is properly cleared when going from one value type to another — e.g., - when going from `unsafe` back to `null`. -- The `map` updater throws immediately when given non-array input. Previously, - it only threw _just before_ it was bound as content. -- Dummy content cursor is no longer appended to end of template. This was an - innocuous off-by-one error when creating instrumented html from the tagged - template strings. +- Transitions from different content values should all now work for the default + template engine. For example, you previously could not change from a text + value to an array. Additionally, state is properly cleared when going from one + value type to another — e.g., when going from `unsafe` back to `null` (#223). +- The `map` updater throws immediately when given non-array input for the + default template engine. Previously, it only threw when it was bound (#222). +- The `map` updater throws if the return value from the provided `identify` + callback returns a duplicate value (#218). +- Dummy content cursor is no longer appended to end of template for the default + template engine. This was an innocuous off-by-one error when creating + instrumented html from the tagged template strings (#221). ## [1.1.1] - 2024-11-09 diff --git a/doc/RECIPES.md b/doc/RECIPES.md new file mode 100644 index 0000000..739651a --- /dev/null +++ b/doc/RECIPES.md @@ -0,0 +1,103 @@ +# Recipes + +Part of the [philosophy](../README.md#project-philosophy) for `x-element` is to +implement only a minimal set of functionality. Rather than build a bespoke +feature to cover each-and-every use case — we simply document how to achieve +some desired outcomes via “recipes” for less common situations. + +## How do I instantiate trusted markup? + +In certain, _rare_ occasions, it’s acceptable to instantiate a pre-defined +markup string as DOM using `innerHTML`. Rather than supply some sort of special +function (e.g., `carefulWhatYouAreDoingIsUnsafe`), we trust that authors will +understand the hazards of `innerHTML` and will use with care. The basic pattern +here is to instantiate your markup with a `