Patterns
Patterns copied to clipboard
Global pat-inject
Context
In the beginning when the web was void and empty we used a pat-inject statement here and there to smoothen things up. Today I fill my days writing class="pat-inject" data-pat-inject="history: record"
on every possible link. History: record is something that we want almost every time.
Problem
We could make it a default and have history: no-record for the exceptions. But the pat-inject class is still needed on every link and form which is a lot of work. Also we have no control over links in rich texts written by editors. And those should use inject too for smooth operation of applications such as Quaive.
Proposal
I propose to introduce a 'selector' property for pat-inject. The selector property allow for pointing to the element(s) on which the inject statement should take effect. The default value is 'self' like it is now. The selector would within the context of the container element the statement is placed on.
Example:
<body class="pat-inject"
data-pat-inject="selector: a,form; source: #main; target: #main; history: record">
The above example would apply basic injection behaviour for everthing that loads content on the site.
It should be possible to overrule the inject statement. For instance when an injection is sometimes not desired or when another combination of source and target is desired.
To a designer it would feel natural to overrule property by property. But I think that would be too complex. I would propose to overrule pat-inject on a link or form element altogether simply by putting a class pat-inject on the element. It will accept only its own properties.
When no injection is required on an element that matches the pat-inject selector of its container, I propose the following: class="pat-inject" data-pat-inject="none"
.
Note: the current pat-inject documentation mentions that a property 'selector' already exists, but I think that that's a typo and that that should be 'source'.
I like the global injection idea.
The selector
documentation is a typo (fixed in PR #724) but there is really also a selector
property which can be defined as default if no source and target are defined (renamed in PR #724).
I'm not sure if renaming the selector
property to defaultSelector
won't break things...
Will be made obsolete by https://github.com/quaive/ploneintranet.prototype/issues/1064