-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use renderer2 to manipulate elements (#687)
* Add renderer2 * Fix tests * Fix tests and remove addClass utility * Remove angular v2 from testing * Add breaking change description * Use angular API to check class and remove element
- Loading branch information
1 parent
3935094
commit a487457
Showing
9 changed files
with
42 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,3 @@ | ||
export function addClass(element: any, name: string) { | ||
if (element.nodeType === 1) { | ||
if (element.classList) { | ||
element.classList.add(name); | ||
} else { | ||
element.className = element.className ? element.className + ' ' + name : name; | ||
} | ||
|
||
} | ||
}; | ||
|
||
export function hasClass(element: any, name: string) { | ||
let result; | ||
|
||
if (element.classList) { | ||
result = element.classList.contains(name); | ||
} else { | ||
result = element.className.split(' ').indexOf(name) >= 0; | ||
} | ||
|
||
return result; | ||
}; | ||
|
||
export function getElement(element: any) { | ||
return element.get ? element.get(0) : element; | ||
}; | ||
|
||
export function removeElement(element: any) { | ||
let node = getElement(element), | ||
parentNode = node && node.parentNode; | ||
if (parentNode) { | ||
parentNode.removeChild(node); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters