Skip to content

Commit

Permalink
Move hasClass to css namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
demiazz committed May 4, 2017
1 parent 827c9ae commit 91893b8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion spec/hasClass.spec.js → spec/css/has-class.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { hasClass } from "../src";
import { hasClass } from "../../src";

describe("hasClass", () => {
afterEach(clearFixtures);
Expand Down
9 changes: 9 additions & 0 deletions src/css/has-class.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* @flow */

import type { CSSClass } from "../types";

function hasClass(element: Element, cssClass: CSSClass): boolean {
return element.classList.contains(cssClass);
}

export default hasClass;
9 changes: 2 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/* @flow */

import type { Selector } from "./types";
import type { CSSClass, Selector } from "./types";

import { html, body } from "./aliases";
import hasClass from "./css/has-class";
import query from "./queries/query";
import queryAll from "./queries/query-all";
import matches from "./traversing/matches";
Expand All @@ -13,8 +14,6 @@ import parentsBy from "./traversing/parents-by";

/* Types */

type CSSClass = string;

type EventDetails = { [key: string]: mixed };

type EventListener = (event: Event) => mixed;
Expand All @@ -25,10 +24,6 @@ type PredicateFn = (element: Element) => boolean;

/* Classes */

function hasClass(element: Element, cssClass: CSSClass): boolean {
return element.classList.contains(cssClass);
}

function addClass(element: Element, cssClass: CSSClass): boolean {
const result = !hasClass(element, cssClass);

Expand Down
2 changes: 2 additions & 0 deletions src/types.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* @flow */

export type CSSClass = string;

export type Elements = Array<Element>;

export type Predicate = (element: Element) => boolean;
Expand Down

0 comments on commit 91893b8

Please sign in to comment.