Matt-Esch / virtual-dom

A Virtual DOM and diffing algorithm
MIT License
11.67k stars 777 forks source link

bug: virtual-dom does not notice regex props changes #431

Open 0x24a537r9 opened 7 years ago

0x24a537r9 commented 7 years ago

If I have a regex prop, virtual-dom will never update it. See http://requirebin.com/?gist=013435cf5fc871d9f7b81eac75a94d1e or below:

var h = require('virtual-dom/h');
var diff = require('virtual-dom/diff');
var patch = require('virtual-dom/patch');
var createElement = require('virtual-dom/create-element');
var prettyFormat = require('pretty-format');

const before = h('div', {}, [
  h('div', {regex: /a/}, null),
]);
const after = h('div', {}, [
  h('div', {regex: /b/}, null),
]);

console.info(prettyFormat(diff(before, after)));

logs:

Object {
  "a": VirtualNode {
    "children": Array [
      VirtualNode {
        "children": Array [],
        "count": 0,
        "descendantHooks": false,
        "hasThunks": false,
        "hasWidgets": false,
        "hooks": undefined,
        "key": undefined,
        "namespace": null,
        "properties": Object {
          "regex": /a/,
        },
        "tagName": "DIV",
      },
    ],
    "count": 1,
    "descendantHooks": false,
    "hasThunks": false,
    "hasWidgets": false,
    "hooks": undefined,
    "key": undefined,
    "namespace": null,
    "properties": Object {},
    "tagName": "DIV",
  },
}

Note the lack of patches. I would expect a PROPS patch at index 0 for the regex prop.