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

refactor: move supported views array to file #147

Merged
merged 2 commits into from
Apr 26, 2019
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions lib/babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const hyperx = require('hyperx')
const SVG_TAGS = require('./svg-tags')
const BOOL_PROPS = require('./bool-props')
const DIRECT_PROPS = require('./direct-props')
const SUPPORTED_VIEWS = require('./supported-views')

const SVGNS = 'http://www.w3.org/2000/svg'
const XLINKNS = 'http://www.w3.org/1999/xlink'
Expand Down Expand Up @@ -49,7 +50,6 @@ function removeBindingImport (binding) {

module.exports = (babel) => {
const t = babel.types
const nanohtmlModuleNames = ['nanohtml', 'bel', 'yo-yo', 'choo/html', 'hui/html']

/**
* Returns an object which specifies the custom elements by which a built-in is extended.
Expand Down Expand Up @@ -347,7 +347,7 @@ module.exports = (babel) => {
}

const importFrom = firstArg.value
return nanohtmlModuleNames.indexOf(importFrom) !== -1
return SUPPORTED_VIEWS.indexOf(importFrom) !== -1
}

return {
Expand Down Expand Up @@ -410,7 +410,7 @@ module.exports = (babel) => {
*/
ImportDeclaration (path, state) {
const importFrom = path.get('source').node.value
if (nanohtmlModuleNames.indexOf(importFrom) !== -1) {
if (SUPPORTED_VIEWS.indexOf(importFrom) !== -1) {
const specifier = path.get('specifiers')[0]
if (specifier.isImportDefaultSpecifier()) {
this.nanohtmlBindings.add(path.scope.getBinding(specifier.node.local.name))
Expand Down
2 changes: 1 addition & 1 deletion lib/browserify-transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ var hyperx = require('hyperx')
var acorn = require('acorn')
var path = require('path')
var SVG_TAGS = require('./svg-tags')
var SUPPORTED_VIEWS = require('./supported-views')

var SUPPORTED_VIEWS = ['nanohtml', 'bel', 'yo-yo', 'choo', 'choo/html', 'hui/html']
var DELIM = '~!@|@|@!~'
var VARNAME = 'nanohtml'
var SVGNS = 'http://www.w3.org/2000/svg'
Expand Down
8 changes: 8 additions & 0 deletions lib/supported-views.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = [
'nanohtml',
'bel',
'yo-yo',
'choo/html',
'choo', // Support choo 3.x-style require('choo').view``
'hui/html'
]