Skip to content

Commit

Permalink
Move remove to manipulation namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
demiazz committed May 4, 2017
1 parent 0327017 commit 0d00d22
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
8 changes: 2 additions & 6 deletions spec/remove.spec.js → spec/manipulation/remove.spec.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import { remove } from "../src";
import { remove } from "../../src";

describe("remove", () => {
it("removes element if attached to DOM", () => {
useFixture(
`
<div class="root"></div>
`
);
useFixture(`<div class="root"></div>`);

const subject = document.querySelector(".root");

Expand Down
15 changes: 1 addition & 14 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import delegate from "./events/delegate";
import dispatch from "./events/dispatch";
import on from "./events/on";
import once from "./events/once";
import remove from "./manipulation/remove";
import query from "./queries/query";
import queryAll from "./queries/query-all";
import matches from "./traversing/matches";
Expand Down Expand Up @@ -100,20 +101,6 @@ function closest(
return parentBy(element, condition);
}

/* Manipulate */

function remove(element: Element): boolean {
const parentElement = parent(element);

if (parentElement) {
parentElement.removeChild(element);

return true;
}

return false;
}

/* Exports */

export {
Expand Down
17 changes: 17 additions & 0 deletions src/manipulation/remove.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* @flow */

import parent from "../traversing/parent";

function remove(element: Element): boolean {
const parentElement = parent(element);

if (parentElement) {
parentElement.removeChild(element);

return true;
}

return false;
}

export default remove;

0 comments on commit 0d00d22

Please sign in to comment.