Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Warning: Users of this library are responsible for sanitizing content.
- [Extending](#extending)⁣
- [Performance](#performance)⁣
- Migrating (`docs/`)
- [5.0 to 5.1](./docs/migrating-from-050000-050100.md)
- [4.x to 5.0](#migrating-from-4x-to-50)⁣
- [5.0 to 5.1](https://github.com/8fold/php-html-builder/blob/main/docs/migrating-from-050000-050100.md)
- [4.x to 5.0](https://github.com/8fold/php-html-builder/blob/main/docs/migrating-from-04x-050000.md)⁣
- [Details](#details)
- [Other](#other)⁣

Expand Down
7 changes: 3 additions & 4 deletions docs/migrating-from-04x-050000.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
- [Text controls](#text-controls-containing-div) add a containing `div` element
- [All form controls have](#normalized-form-control-property-methods) `containerProps()`, `labelProps()`, and `inputProps()`; `FieldSet::labelProps()` targets the `legend` element
- `id()` is available on `TextInput`, `EmailInput`, `Password`, `TextArea`, and `Select`; allowing you to override the default `id` based on `name`

- Updated or fixed:
- [`PropertyInterface`](https://github.com/8fold/php-html-builder/blob/main/src/PropertyInterface.php) extends PHP's `Stringable`; add `public function __toString(): string` alongside `prop()` and `props()`.
- `Select` [`radio()` and `checkbox()` IDs](#radio-and-checkbox-ids) use `<control-id>-option-<zero-based-index>` instead of `<name>-<option-value>`
- `warningMessage` accessibility improved for each form control; `Fieldset` renders one warning for the group and [does not inspect child elements](#fieldset-does-not-inspect-children)
- `warningMessage` accessibility improved for each form control; `Fieldset` renders one warning for the group and [does not inspect child elements](#fieldset-does-not-inspect-child-elements)
- Deprecated:
- [`wrapperProps()` on form controls](#wrapper-on-form-controls)
- [`wrapperProps()` on form controls](#wrapperprops-on-form-controls)
- Deleted: None

## New
Expand Down Expand Up @@ -56,7 +55,7 @@ Native HTML parsing normalizes CR and CRLF line endings to LF; browsers apply th

`Select` defaults to a single dropdown.

```php
```html
<select name="sample">
<option value="1">1</option>
<option value="2">2</option>
Expand Down
21 changes: 15 additions & 6 deletions docs/migrating-from-050000-050100.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ While not a major release, it could have been, but the potential breaking change

Otherwise, this is a quality of life improvement release.

- [New](#new)
- New
- [`EmptyElement`](#emptyelement) component
- [Updated](#updated)
- Updated
- (could cause frustration) [Static analysis](#static-analysis) may throw if the element name in an `Element` or `EmptyElement` static creation is not in the HTML specification, is not declared empty by the HTML specification, or both.
- (see previous) Removed all [`ignoreErrors`](https://phpstan.org/user-guide/ignoring-errors#ignoring-in-configuration-file) from the PHPStan configuration.
- (see previous) Increased the [PHPStan](https://phpstan.org) level for HTML Builder to 10.
Expand All @@ -21,18 +21,27 @@ Otherwise, this is a quality of life improvement release.

The first quality of life improvement is introducing an explicit way to create empty elements.

The examples in the `EmptyElement` section in the [README](../README.md#emptyelement) demonstrates the improvement.
The examples in the `EmptyElement` section in the [README](https://github.com/8fold/php-html-builder#emptyelement) demonstrates the improvement.

In short:

```php
use Eightfold\HtmlBuilder\Element;
use Eightfold\HtmlBuilder\EmptyElement;

Element::img()->omitEndTag()->prop('id cat-picture', 'src /path/to/image.png');
// line breaks added for emphasis
Element::img()
->omitEndTag()
->prop(
'id cat-picture',
'src /path/to/image.png'
);

// becomes
EmptyElement::img('id cat-picture', 'src /path/to/image.png');
EmptyElement::img(
'id cat-picture',
'src /path/to/image.png'
);
```

Outputs:
Expand All @@ -54,7 +63,7 @@ ignoreErrors:
- '#Call to an undefined static method Eightfold\\HtmlBuilder\\Element::(.*)#'
```

We introduced the ‘create()’ named constructor, which gave a specific pattern for creating custom components and allowed users to avoid ignoring the static analysis error (the second workaround):
We introduced the `create()` named constructor, which gave a specific pattern for creating custom components and allowed users to avoid ignoring the static analysis error (the second workaround):

```php
Element::create('p', 'Hello, World!');
Expand Down
Loading