Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing console.assert to node assert #40

Merged
merged 1 commit into from
Jun 20, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions lib/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
const HTML_ELEMENT_NAMES = new Set(require('./html-elements.json'))
const SVG_ELEMENT_NAMES = new Set(require('./svg-elements.json'))
const VOID_ELEMENT_NAMES = new Set(require('./void-elements.json'))
const assert = require('assert')

// ------------------------------------------------------------------------------
// Exports
Expand Down Expand Up @@ -63,7 +64,7 @@ module.exports = {
* @returns {boolean} `true` if the node is the root element.
*/
isRootElement (node) {
console.assert(node && node.type === 'VElement')
assert(node && node.type === 'VElement')

return (
node.parent.type === 'Program' ||
Expand All @@ -77,7 +78,7 @@ module.exports = {
* @returns {ASTNode|null} The previous sibling element.
*/
prevSibling (node) {
console.assert(node && node.type === 'VElement')
assert(node && node.type === 'VElement')
let prevElement = null

for (const siblingNode of (node.parent && node.parent.children) || []) {
Expand All @@ -100,7 +101,7 @@ module.exports = {
* @returns {boolean} `true` if the start tag has the directive.
*/
hasAttribute (node, name, value) {
console.assert(node && node.type === 'VStartTag')
assert(node && node.type === 'VStartTag')
return node.attributes.some(a =>
!a.directive &&
a.key.name === name &&
Expand All @@ -119,7 +120,7 @@ module.exports = {
* @returns {boolean} `true` if the start tag has the directive.
*/
hasDirective (node, name, argument) {
console.assert(node && node.type === 'VStartTag')
assert(node && node.type === 'VStartTag')
return node.attributes.some(a =>
a.directive &&
a.key.name === name &&
Expand All @@ -133,7 +134,7 @@ module.exports = {
* @returns {boolean} `true` if the attribute has their value.
*/
hasAttributeValue (node) {
console.assert(node && node.type === 'VAttribute')
assert(node && node.type === 'VAttribute')
return (
node.value != null &&
(node.value.expression != null || node.value.syntaxError != null)
Expand All @@ -148,7 +149,7 @@ module.exports = {
* @returns {ASTNode} The found attribute.
*/
getAttribute (node, name, value) {
console.assert(node && node.type === 'VStartTag')
assert(node && node.type === 'VStartTag')
return node.attributes.find(a =>
!a.directive &&
a.key.name === name &&
Expand All @@ -167,7 +168,7 @@ module.exports = {
* @returns {ASTNode} The found directive.
*/
getDirective (node, name, argument) {
console.assert(node && node.type === 'VStartTag')
assert(node && node.type === 'VStartTag')
return node.attributes.find(a =>
a.directive &&
a.key.name === name &&
Expand All @@ -181,7 +182,7 @@ module.exports = {
* @returns {boolean} `true` if the previous sibling element has `if` or `else-if` directive.
*/
prevElementHasIf (node) {
console.assert(node && node.type === 'VElement')
assert(node && node.type === 'VElement')

const prev = this.prevSibling(node)
return (
Expand All @@ -199,7 +200,7 @@ module.exports = {
* @returns {boolean} `true` if the node is a custom component.
*/
isCustomComponent (node) {
console.assert(node && node.type === 'VStartTag')
assert(node && node.type === 'VStartTag')

const name = node.id.name
return (
Expand All @@ -215,7 +216,7 @@ module.exports = {
* @returns {boolean} `true` if the name is a HTML element name.
*/
isHtmlElementName (name) {
console.assert(typeof name === 'string')
assert(typeof name === 'string')

return HTML_ELEMENT_NAMES.has(name.toLowerCase())
},
Expand All @@ -226,7 +227,7 @@ module.exports = {
* @returns {boolean} `true` if the name is a SVG element name.
*/
isSvgElementName (name) {
console.assert(typeof name === 'string')
assert(typeof name === 'string')

return SVG_ELEMENT_NAMES.has(name.toLowerCase())
},
Expand All @@ -237,7 +238,7 @@ module.exports = {
* @returns {boolean} `true` if the name is a void element name.
*/
isVoidElementName (name) {
console.assert(typeof name === 'string')
assert(typeof name === 'string')

return VOID_ELEMENT_NAMES.has(name.toLowerCase())
}
Expand Down