You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The rules that define whether a visit will be considered a fragment visit. Each rule consists of
@@ -175,7 +183,7 @@ The rule's `from`/`to` paths are converted to a regular expression by [path-to-r
175
183
{
176
184
from: ['/users', '/users/:filter?'],
177
185
to: ['/users', '/users/:filter?'],
178
-
containers: ['#user-list'],
186
+
containers: ['#user-list']
179
187
}
180
188
];
181
189
}
@@ -196,7 +204,7 @@ Required, Type: `string[]` – Selectors of containers to be replaced if the vis
196
204
**Notes**
197
205
198
206
-**only IDs and no nested selectors are allowed**. `#my-element` is valid, while
199
-
`.my-element` or `#wrap #child` both will throw an error.
207
+
`.my-element` or `#wrap #child` both will throw an error.
200
208
- if **any** of the selectors in `containers` doesn't return a match in the current document, the rule will be skipped.
201
209
- Fragment elements **must either match a swup container or be a descendant of one of them**
202
210
@@ -384,7 +392,9 @@ This will work fine, until you apply a `transform` to one of the modal's parent
384
392
385
393
```css
386
394
html.is-changing.transition-main {
387
-
transition: opacity 250ms, transform 250ms;
395
+
transition:
396
+
opacity 250ms,
397
+
transform 250ms;
388
398
}
389
399
html.is-animating.transition-main {
390
400
opacity: 0;
@@ -398,7 +408,7 @@ The reason for this is that a CSS `transform` establishes a [containing block fo
398
408
You have two options to fix this:
399
409
400
410
1. Don't apply CSS `transform`s to any of the parents of a modal
401
-
2. Use `<detail open>` for the modal:
411
+
2. Use `<dialog open>` for the modal:
402
412
403
413
```diff
404
414
- <main id="overlay" class="modal">
@@ -429,3 +439,66 @@ The first `<main>` element in a document will be considered the main content by
429
439
**Cons**:
430
440
431
441
- Wrapping your `<main>` content inside a `<dialog>` will produce [semantically incorrect markup](https://stackoverflow.com/a/75007908/586823). We still think it's the cleanest approach for now, until the [Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API) reaches [wider browser support](https://caniuse.com/?search=popover).
442
+
443
+
## API methods
444
+
445
+
Fragment plugin provides a few API functions for advanced use cases. To be able to access those, you'll need to keep a reference to the plugin during instanciation:
Prepends a [rule](#type-signature-rule) to the array of rules.
477
+
478
+
```js
479
+
fragmentPlugin.prependRule({ from: '/foo/', to: '/bar/', containers: ['#foobar'] });
480
+
```
481
+
482
+
### `appendRule(rule)`
483
+
484
+
Appends a [rule](#type-signature-rule) to the array of rules.
485
+
486
+
```js
487
+
fragmentPlugin.prependRule({ from: '/baz/', to: '/bat/', containers: ['#bazbat'] });
488
+
```
489
+
490
+
### `getRules()`
491
+
492
+
Get a **clone**of all registered fragment rules
493
+
494
+
```js
495
+
console.log(fragmentPlugin.getRules());
496
+
```
497
+
498
+
### `setRules(rules)`
499
+
500
+
Overwrite all fragment rules with the provided rules. This methods provides the lowest-level access to the rules. For example, you could use it to remove all rules with the name `foobar`:
0 commit comments