Skip to content

how to handle something like Highcharts #279

Answered by tbranyen
yatesco asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @yatesco I've written a middleware in the past for this, I'm about to take off on a flight, but it was something like this working solution:

import { createTree, innerHTML, toString, use } from 'diffhtml';

use({
  syncTreeHook(vTree) {
    if (vTree.attributes && 'x-preserve' in vTree.attributes) {
      return vTree;
    }
  },
});

const out = createTree();

innerHTML(out, `<b preserve>test</ba>`);
innerHTML(out, `<b preserve>never changed</ba>`);

console.log(toString(out), 'contents will not update', 'test');

The idea is to skip diffing (sync phase) and simply return the previously rendered node with the attribute x-preserve or whatever you want to call it.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@yatesco
Comment options

Answer selected by yatesco
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants