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

对深层数据执行 mv 操作后,from 对象没有被移除 #15

Open
jaryway opened this issue Feb 1, 2021 · 3 comments
Open

对深层数据执行 mv 操作后,from 对象没有被移除 #15

jaryway opened this issue Feb 1, 2021 · 3 comments

Comments

@jaryway
Copy link
Contributor

jaryway commented Feb 1, 2021

// jsonuri.set(vm.data, "batters/batter/length", 1);
var dta;
jsonuri.set(
  [
    {
      name: "a",
      // 0/children
      children: [
        // 0/children/0
        { name: "a-0" },
        // 0/children/1
        {
          name: "a-1",
          // 0/children/1/children
          children: [
            // 0/children/1/children/0
            { name: "a-1-0" },
            // 0/children/1/children/1
            { name: "a-1-1" },
            { name: "a-1-2" },
            { name: "a-1-3" },
          ],
        },
        // 0/children/2
        {
          name: "a-2",
          // 0/children/2/children
          children: [
            // 0/children/2/children/0
            { name: "a-2-0" },
            // 0/children/2/children/1
            {
              name: "a-2-1",
              // 0/children/2/children/1/children
              children: [
                { name: "a-2-1-0" },
                // 0/children/2/children/1/children/1
                { name: "a-2-1-1" },
                { name: "a-2-1-2" },
                { name: "a-2-1-3" },
              ],
            },
            { name: "a-2-2" },
            { name: "a-2-3" },
          ],
        },
      ],
    },
  ],
  "0/name",
  "aaaaa"
);
var data = [
  {
    name: "a",
    // 0/children
    children: [
      // 0/children/0
      { name: "a-0" },
      // 0/children/1
      {
        name: "a-1",
        // 0/children/1/children
        children: [
          // 0/children/1/children/0
          { name: "a-1-0" },
          // 0/children/1/children/1
          { name: "a-1-1" },
          // 0/children/1/children/2
          { name: "a-1-2" },
          // 0/children/1/children/3
          { name: "a-1-3" },
        ],
      },
      // 0/children/2
      {
        name: "a-2",
        // 0/children/2/children
        children: [
          // 0/children/2/children/0
          { name: "a-2-0" },
          // 0/children/2/children/1
          {
            name: "a-2-1",
            // 0/children/2/children/1/children
            children: [
              { name: "a-2-1-0" },
              // 0/children/2/children/1/children/1
              { name: "a-2-1-1" },
              { name: "a-2-1-2" },
              { name: "a-2-1-3" },
            ],
          },
          { name: "a-2-2" },
          { name: "a-2-3" },
        ],
      },
    ],
  },
];
// 把 a-2-1-1 移到 0/children/0 前面;

// 期望:a-2-1-1 移到 0/children/0 前面,并且从 0/children/2/children/1/children/1 移除
// 实际:a-2-1-1 移到 0/children/0 前面,但未从 0/children/2/children/1/children/1 移除

jsonuri.mv(data, "0/children/2/children/1/children/1", "0/children/0", "before");
console.log(data);
@jaryway
Copy link
Contributor Author

jaryway commented Feb 1, 2021

@haozi

@newbeea
Copy link

newbeea commented Jul 14, 2021

看了源码,只对上一层做了处理,深层原数据就没有进行rm

@WilliamALiang
Copy link

看这个逻辑应该只是写了同层级移动的逻辑,不同层级往前移动,先进行移动后进行删除就有问题了

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

3 participants