I wonder if there is some sort of imperative-declarative model that we could adopt here? I mean, allow script to specify the distribution logic, but do it with a static model. After all, what is being asked for is a relatively simple mapping from candidate node to content distribution point.
I’m just thinking out loud here, but what about something like:
assignDistributionMap( {
source: {
/* examples… */
tagName: “foo”,
className: “bar”
childIndex: 2,
selector: “”,
textContains: “some text”,
},
target:
} );
And then providing a mechanism to notify the app when the set of distribution targets changes (which should be a relatively rare occurrence)?
Thinking creatively, this could be modified to be an ordered list of “fill” candidate rules, where the first filled rule takes the selection…?
This could also be used to provide flags indicating whether children, or subtrees should be considered for distribution candidates, etc.