Skip to content

Commit

Permalink
Merge dabbf8d into d3f5844
Browse files Browse the repository at this point in the history
  • Loading branch information
sventschui committed May 12, 2019
2 parents d3f5844 + dabbf8d commit 37f3292
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/create-element.js
@@ -1,5 +1,6 @@
import options from './options';
import { assign } from './util';
import { EMPTY_OBJ } from './constants';

/**
* Create an virtual node (used for JSX)
Expand Down Expand Up @@ -62,7 +63,7 @@ export function createVNode(type, props, key, ref) {
_lastDomChild: null,
_component: null
};
vnode._self = vnode;
vnode._self = EMPTY_OBJ;

if (options.vnode) options.vnode(vnode);

Expand Down
4 changes: 2 additions & 2 deletions src/diff/index.js
Expand Up @@ -34,10 +34,10 @@ export function diff(parentDom, newVNode, oldVNode, context, isSvg, excessDomChi
let c, tmp, isNew, oldProps, oldState, snapshot,
newType = newVNode.type, clearProcessingException;

// When passing through createElement it assigns the object
// When passing through createElement it assigns an object
// ref on _self, to prevent JSON Injection we check if this attribute
// is equal.
if (newVNode._self!==newVNode) return null;
if (newVNode._self!==EMPTY_OBJ) return null;

if (tmp = options.diff) tmp(newVNode);

Expand Down
3 changes: 2 additions & 1 deletion test/shared/createElement.test.js
@@ -1,6 +1,7 @@
import { createElement as h } from '../../src/index';
// import { VNode } from '../../src/vnode';
import { expect } from 'chai';
import { EMPTY_OBJ } from '../../src/constants';

/*eslint-env browser, mocha */

Expand Down Expand Up @@ -34,7 +35,7 @@ describe('createElement(jsx)', () => {

it('should set VNode._self property to prevent json injection', () => {
const vnode = <span />;
expect(vnode._self).to.equal(vnode);
expect(vnode._self).to.equal(EMPTY_OBJ);
});

it('should set VNode#props property', () => {
Expand Down

0 comments on commit 37f3292

Please sign in to comment.