Skip to content
This repository has been archived by the owner on May 19, 2023. It is now read-only.

Commit

Permalink
fix: file paths
Browse files Browse the repository at this point in the history
  • Loading branch information
aidenybai committed Feb 14, 2021
1 parent d1e21dc commit 80f439a
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 24 deletions.
4 changes: 2 additions & 2 deletions src/__test__/browser.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _browser from '../browser';
import { getCustomProp } from '../core/utils/customProp';
import { getElementCustomProp } from '../core/utils/elementCustomProp';

// Reset to clean, uninitialized template
const reset = () => {
Expand All @@ -14,7 +14,7 @@ const reset = () => {
const validateComponentFunctionality = (error = false) => {
const componentElement = document.querySelector('body > div') as HTMLElement;
const componentText = componentElement.querySelector('p') as HTMLElement;
const component = getCustomProp(componentElement, '__l');
const component = getElementCustomProp(componentElement, '__l');

if (error) {
expect(component).toBeUndefined();
Expand Down
4 changes: 2 additions & 2 deletions src/__test__/component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { component, Component } from '../component';
import reactive from '../core/reactive';
import { directives } from '../core/directive';
import { getCustomProp } from '../core/utils/customProp';
import { getElementCustomProp } from '../core/utils/elementCustomProp';

describe('.component', () => {
it('should create and mount component properly', () => {
Expand Down Expand Up @@ -34,7 +34,7 @@ describe('.component', () => {
const app = component(state);
app.mount(el);

expect(getCustomProp(el, '__l')).toEqual(app);
expect(getElementCustomProp(el, '__l')).toEqual(app);
});

it('should register custom directive', () => {
Expand Down
16 changes: 8 additions & 8 deletions src/core/directives/__test__/for.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { forDirective } from '../for';
import compute from '../../utils/computeExpression';
import { setCustomProp } from '../../utils/customProp';
import { setElementCustomProp } from '../../utils/elementCustomProp';

describe('.forDirective', () => {
it('should join the state array into HTML', (done) => {
Expand All @@ -9,7 +9,7 @@ describe('.forDirective', () => {
const state = { foo: ['bar', 'bar', 'bar'] };
const data = { value: expression, compute: compute(expression, el), deps: ['foo'] };

setCustomProp(el, '__l_for_template', '<li l-text="this.bar"></li>');
setElementCustomProp(el, '__l_for_template', '<li l-text="this.bar"></li>');
el.innerHTML = '<li l-text="this.bar"></li>';

forDirective({
Expand All @@ -35,7 +35,7 @@ describe('.forDirective', () => {
const state = { foo: ['bar', 'bar', 'bar'] };
const data = { value: expression, compute: compute(expression, el), deps: ['foo'] };

setCustomProp(el, '__l_for_template', '<li l-text="this.bar + this.i"></li>');
setElementCustomProp(el, '__l_for_template', '<li l-text="this.bar + this.i"></li>');

el.innerHTML = '<li l-text="this.bar + this.i"></li>';
forDirective({
Expand All @@ -57,7 +57,7 @@ describe('.forDirective', () => {
const state = { foo: ['bar', 'bar', 'bar'] };
const data = { value: expression, compute: compute(expression, el), deps: ['foo'] };

setCustomProp(el, '__l_for_template', '<li></li>');
setElementCustomProp(el, '__l_for_template', '<li></li>');

forDirective({
el,
Expand All @@ -76,8 +76,8 @@ describe('.forDirective', () => {
const state = { foo: ['bar', 'bar'] };
const data = { value: expression, compute: compute(expression, el), deps: ['foo'] };

setCustomProp(el, '__l_for_template', '<li></li>');
setCustomProp(el, '__l_for_state', ['bar', 'bar']);
setElementCustomProp(el, '__l_for_template', '<li></li>');
setElementCustomProp(el, '__l_for_state', ['bar', 'bar']);

el.innerHTML = '<li></li>';
forDirective({
Expand All @@ -97,8 +97,8 @@ describe('.forDirective', () => {
const state = { foo: ['bar', 'bar', 'bar'] };
const data = { value: expression, compute: compute(expression, el), deps: ['foo'] };

setCustomProp(el, '__l_for_template', '<li></li>');
setCustomProp(el, '__l_for_state', ['bar', 'bar', 'bar']);
setElementCustomProp(el, '__l_for_template', '<li></li>');
setElementCustomProp(el, '__l_for_state', ['bar', 'bar', 'bar']);

el.innerHTML = '<li></li><li></li><li></li><li></li>';
forDirective({
Expand Down
8 changes: 4 additions & 4 deletions src/core/directives/__test__/if.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ifDirective } from '../if';
import compute from '../../utils/computeExpression';
import { getCustomProp } from '../../utils/customProp';
import { getElementCustomProp } from '../../utils/elementCustomProp';

describe('.ifDirective', () => {
it('should conditionally remove element', () => {
Expand All @@ -22,7 +22,7 @@ describe('.ifDirective', () => {
node,
});

expect(getCustomProp(node.el, '__l_if_template')).toEqual(true);
expect(getElementCustomProp(node.el, '__l_if_template')).toEqual(true);
expect(node.el.tagName).toEqual('TEMPLATE');
expect(node.el.nextElementSibling).toBeFalsy();
});
Expand All @@ -49,7 +49,7 @@ describe('.ifDirective', () => {
node,
});

expect(getCustomProp(node.el, '__l_if_template')).toEqual(true);
expect(getElementCustomProp(node.el, '__l_if_template')).toEqual(true);
expect(node.el.tagName).toEqual('TEMPLATE');
expect(node.el.nextElementSibling).toBeDefined();
});
Expand All @@ -76,7 +76,7 @@ describe('.ifDirective', () => {
node,
});

expect(getCustomProp(node.el, '__l_if_template')).toEqual(true);
expect(getElementCustomProp(node.el, '__l_if_template')).toEqual(true);
expect(node.el.tagName).toEqual('TEMPLATE');
expect(node.el.nextElementSibling).toBeDefined();
});
Expand Down
4 changes: 2 additions & 2 deletions src/core/directives/__test__/on.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { fireEvent } from '@testing-library/dom';

import { onDirective } from '../on';
import compute from '../../utils/computeExpression';
import { getCustomProp } from '../../utils/customProp';
import { getElementCustomProp } from '../../utils/elementCustomProp';

describe('.onDirective', () => {
it('should attach click event listener', () => {
Expand All @@ -20,7 +20,7 @@ describe('.onDirective', () => {
});

fireEvent.click(el);
expect(typeof getCustomProp(el, '__l_on_registered')).toEqual('boolean');
expect(typeof getElementCustomProp(el, '__l_on_registered')).toEqual('boolean');
expect(callback).toBeCalledTimes(1);

onDirective({
Expand Down
10 changes: 5 additions & 5 deletions src/core/utils/__test__/customProp.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getCustomProp, setCustomProp } from '../customProp';
import { getElementCustomProp, setElementCustomProp } from '../elementCustomProp';

describe('.customProp', () => {
it('should correctly access custom prop', () => {
Expand All @@ -7,15 +7,15 @@ describe('.customProp', () => {
// @ts-ignore
el.__l = 'foo';

expect(getCustomProp(el, 'innerHTML')).toEqual('');
expect(getCustomProp(el, '__l')).toEqual('foo');
expect(getElementCustomProp(el, 'innerHTML')).toEqual('');
expect(getElementCustomProp(el, '__l')).toEqual('foo');
});

it('should correctly mutate custom prop', () => {
const el = document.createElement('div');

setCustomProp(el, '__l', 'foo');
setElementCustomProp(el, '__l', 'foo');

expect(getCustomProp(el, '__l')).toEqual('foo');
expect(getElementCustomProp(el, '__l')).toEqual('foo');
});
});
3 changes: 2 additions & 1 deletion src/core/utils/elementCustomProp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
export const getElementCustomProp = (el: HTMLElement, prop: string) => el[prop];

// @ts-ignore
export const setElementCustomProp = (el: HTMLElement, prop: string, value: any) => (el[prop] = value);
export const setElementCustomProp = (el: HTMLElement, prop: string, value: any) =>
(el[prop] = value);

0 comments on commit 80f439a

Please # to comment.