Skip to content

Commit

Permalink
chore: 불필요한 코드 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
류제천 authored and 류제천 committed Nov 11, 2022
1 parent 1b44679 commit cec268a
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions js/router.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const route = (event) => {
event = event || window.event;
event.preventDefault();
window.history.pushState({}, "", event.target.href);
handleLocation();
window.location.hash = event.target.hash;
};

const routes = {
Expand All @@ -28,13 +27,10 @@ const handleLocation = async () => {
};

const GoToLorem = () => {
window.history.pushState({}, "", "#lorem");
// window.location.hash = "#lorem";
handleLocation();
window.location.hash = "#lorem";
};

// window.onpopstate = handleLocation; // 뒤로가기도 hashchange 이벤트 감지에 포함되어 동작함.
window.route = route;
// window.route = route; // js 파일을 쪼개어 module로 사용할 때 변수나 함수를 전역화할 필요 있음

window.addEventListener("hashchange", handleLocation);

Expand Down

0 comments on commit cec268a

Please sign in to comment.