Skip to content

Commit

Permalink
chore: prettier content
Browse files Browse the repository at this point in the history
  • Loading branch information
aidenybai committed Jun 14, 2021
1 parent 42bd946 commit 9dac8d1
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
9 changes: 8 additions & 1 deletion src/__test__/m.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,14 @@ describe('.m', () => {
});

it('should create vnode with deeply nested children', () => {
expect(h('div', undefined, 'foo', h('div', undefined, 'bar', h('div', undefined, 'baz', h('div', undefined, 'boo'))))).toEqual({
expect(
h(
'div',
undefined,
'foo',
h('div', undefined, 'bar', h('div', undefined, 'baz', h('div', undefined, 'boo'))),
),
).toEqual({
tag: 'div',
children: [
'foo',
Expand Down
8 changes: 6 additions & 2 deletions src/__test__/patch.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,16 @@ describe('.patch', () => {
expect(el.id).toEqual('app');
expect(el.title).toEqual('bar');

patchProps(<HTMLElement>el, { title: 'bar', id: 'app', lang: 'pt', spellcheck: false }, { title: 'foo', id: '', lang: '', hidden: true});
patchProps(
<HTMLElement>el,
{ title: 'bar', id: 'app', lang: 'pt', spellcheck: false },
{ title: 'foo', id: '', lang: '', hidden: true },
);

expect(el.id).toEqual('app'); // keeped
expect(el.lang).toEqual('pt'); // keeped
expect(el.title).toEqual('foo'); // updated
expect(el.hidden).toEqual(true); // setted
expect(el.hidden).toEqual(true); // setted
expect(el.spellcheck).toBeFalsy(); // removed
});

Expand Down
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
*/
const OLD_VNODE_FIELD = '__m_old_vnode';

export { OLD_VNODE_FIELD }
export { OLD_VNODE_FIELD };
2 changes: 1 addition & 1 deletion src/m.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { VElement, VFlags, VNode, VProps } from "./structs";
import { VElement, VFlags, VNode, VProps } from './structs';

/**
* Attaches ns props to svg element
Expand Down
6 changes: 3 additions & 3 deletions src/patch.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { OLD_VNODE_FIELD } from './constants';
import { createElement } from './createElement';
import { VElement, VFlags, VNode, VProps } from "./structs";
import { VElement, VFlags, VNode, VProps } from './structs';

/**
* Diffs two VNode props and modifies the DOM node based on the necessary changes
Expand All @@ -24,7 +24,7 @@ export const patchProps = (el: HTMLElement, oldProps: VProps = {}, newProps: VPr
}
delete el[propName];
el.removeAttribute(propName);
})
});
} else {
// Addition/No change/Content modification has occured
[...newPropKeys].forEach((propName) => {
Expand All @@ -34,7 +34,7 @@ export const patchProps = (el: HTMLElement, oldProps: VProps = {}, newProps: VPr
return;
}
el[propName] = newProps[propName];
})
});
}
};

Expand Down

0 comments on commit 9dac8d1

Please sign in to comment.