These are chat archives for assetgraph/assetgraph

5th
Aug 2017
Andreas Lind
@papandreou
Aug 05 09:01
@Munter Seems like this is the only stumbling block left to get all tests to pass after my sweep through all addAsset/addRelation calls in the codebase. I'm fairly excited about the result ;)
I noticed that a bunch of the tests call relation.attach(asset, <position>, <adjacentRelation>) after the relations were initially added. Is that a useful thing in general?
Andreas Lind
@papandreou
Aug 05 09:06
That is, moving a relation to a different place in both the DOM/parseTree, also moving it to the correct place in asset.outgoingRelations?
Peter Müller
@Munter
Aug 05 09:10
There are a bunch of transforms where this is needed. And more will come I think
Andreas Lind
@papandreou
Aug 05 09:12
Okay, then let's get it in there. Good thing I asked before doing away with it, then :)
@Munter What do you think about the other idea of allowing per-asset values of position?
The we'd be able to make this work:
const rel = htmlAsset.addRelation({
    type: 'HtmlPrefetchLink',
    to: otherAsset
}, 'lastInHead');


rel.attach(htmlAsset, 'last');
rel.attach(htmlAsset, 'firstInBody');
rel.attach(htmlAsset, 'after', otherRelation);
Peter Müller
@Munter
Aug 05 09:22
Looks good. I guess the positions will be fully custom to reach relation type
Andreas Lind
@papandreou
Aug 05 09:31
You mean asset type?
Or should each relation type also be able to specify its own?
Andreas Lind
@papandreou
Aug 05 10:45
Reinstated the old Relation#attach behavior now so that it can be called multiple times, and added relation.detach(); calls to the test so that the old nodes don't stick around in the DOM. 0 failing tests now :D
... Until the next handgrenade
Peter Müller
@Munter
Aug 05 12:13
Maybe per asset. I just thought there's a difference between where relations are allowed. Some only go in the head. But I guess that's a special case for HTML relations only
Andreas Lind
@papandreou
Aug 05 12:37
Yeah, ok,I'll try to see if it can be an HtmlRelation thing, at least initially