Skip to content

Commit

Permalink
Further back out erroneously commited test code
Browse files Browse the repository at this point in the history
  • Loading branch information
tbranyen committed May 13, 2020
1 parent 7ee950a commit cff1488
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 63 deletions.
2 changes: 0 additions & 2 deletions packages/diffhtml-components/lib/shared/render-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ export default function renderComponent(vTree, context) {
let instances = null;
let renderTree = null;

console.log('Rendering', vTree.rawNodeName.name);

// Existing component.
if (InstanceCache.has(vTree)) {
instances = InstanceCache.get(vTree);
Expand Down
18 changes: 2 additions & 16 deletions packages/diffhtml-components/lib/shared/set-state.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,12 @@
import { $$vTree, $$render } from '../util/symbols';
import { ComponentTreeCache } from '../util/caches';
import { getBinding } from '../util/binding';
import { $$render } from '../util/symbols';

const Debounce = new WeakMap();
const { assign } = Object;
const { from } = Array;

export default function setState(state) {
this.state = assign({}, this.state, state);

const vTree = this[$$vTree];
const { NodeCache } = getBinding().Internals;
const childTrees = from(ComponentTreeCache.keys()).filter(key => {
const rootTree = ComponentTreeCache.get(key);

if (rootTree === vTree) {
return true;
}
});

if (childTrees.length && !Debounce.has(this) && this.shouldComponentUpdate()) {
console.log('Updating', this.constructor.name);
if (!Debounce.has(this) && this.shouldComponentUpdate()) {
// Only render if we have an instance (has rendered before).
this[$$render]();
}
Expand Down
46 changes: 1 addition & 45 deletions packages/diffhtml-components/test/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,7 @@ describe('Component implementation', function() {
});
});

describe.only('HoC', () => {
describe('HoC', () => {
it('will support a component that returns a new component', () => {
let didMount = 0;

Expand All @@ -1131,50 +1131,6 @@ describe('Component implementation', function() {
equal(this.fixture.innerHTML, '<span>Hello world</span>');
});

it.only('will support forceUpdate with an HoC', () => {
const proxy = ({ children }) => html(children);

const HOC = ChildComponent => class HOCComponent extends Component {
render() {
console.log('here');
return html`<${ChildComponent} />`;
}
};

const WrappedComponent = HOC(proxy);

let instance = null;

class CustomComponent extends Component {
render({ message }) {
return html`
<span>${message}</span>
<${WrappedComponent}>test</${WrappedComponent}>
`;
}

constructor(...args) {
super(...args);

instance = this;
}
}

innerHTML(this.fixture, html`<${CustomComponent} message="Some" />`);

//equal(
// this.fixture.innerHTML.replace(whitespaceEx, ''),
// '<span>Some</span> test',
//);

instance.forceUpdate();

equal(
this.fixture.innerHTML.replace(whitespaceEx, ''),
'<span>Some</span> test',
);
});

it('will support wrapping a component that returns a new component', () => {
let didMount = 0;

Expand Down

0 comments on commit cff1488

Please sign in to comment.