Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After configuring "objectHash", jsondiffpatch.formatters.html ShowUnchanged does not take effect #324

Open
liangxuemin opened this issue Oct 12, 2022 · 0 comments

Comments

@liangxuemin
Copy link

liangxuemin commented Oct 12, 2022

After "objectHash" is configured, jsondiffpatch.formatters.html.showUnchanged cannot show the same value with different positions

  let that = this;
  let secodeLists = JSON.parse(JSON.stringify(secodeData));
  let deltas=null;
  let diffpatcher = jsondiffpatch.create({
    objectHash: function(obj,index) {
      return obj.serviceCode ||obj.columns || '$$index:' + index;
    },
    arrays: {
      // default true, detect items moved inside the array (otherwise they will be registered as remove+add)
      detectMove: true,
      // default false, the value of items moved is not included in deltas
      includeValueOnMove: false
    },
    propertyFilter: function(name, context){
       console.log('name', name, context)
    },
    cloneDiffValues: false
  });
  this.diffpatcher = diffpatcher;
  document.getElementById('visualsuat').innerHTML =''
  tijiaodiff()
  function tijiaodiff(){
    if (!firstData && !secodeLists) return;
    deltas = diffpatcher.diff(firstData, secodeLists);
    // console.log('deltas', deltas, JSON.stringify(deltas))
    if (deltas) {
      that.isDisabled = false;
      document.getElementById('visualsuat').innerHTML = jsondiffpatch.formatters.html.format(deltas, firstData);
    } else {
      document.getElementById('visualsuat').innerHTML ='无对比结果'
    }
    if (!that.showUnchange) {
      jsondiffpatch.formatters.html.hideUnchanged();
    }
  }
  jsondiffpatch.formatters.html.showUnchanged(
    target.checked,
    null,
    800
  );

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant