Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
briancappello committed Oct 7, 2017
1 parent 388c8ec commit 12d67cf
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 11 deletions.
20 changes: 16 additions & 4 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,27 @@ module.exports = function(config) {

webpack: {
module: {
loaders: [
{test: /\.(js|jsx)$/, loaders: ['babel']},
]
rules: [
{
test: /\.(js|jsx)$/,
use: {
loader: 'babel-loader',
options: {
presets: ['env'],
plugins: [
'transform-class-properties',
'transform-react-jsx',
],
},
},
},
],
},
externals: {
react: 'React'
},
resolve: {
root: __dirname
modules: [__dirname, 'node_modules']
}
},
webpackServer: {
Expand Down
16 changes: 11 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"scripts": {
"start": "gulp server",
"prepublish": "babel ./src --out-dir ./lib --plugins=transform-class-properties,transform-react-jsx",
"prepublish": "babel ./src --out-dir ./lib --plugins=transform-class-properties,transform-react-jsx --preset=env",
"test": "karma start --single-run",
"dev-test": "karma start"
},
Expand All @@ -27,8 +27,7 @@
},
"homepage": "https://github.com/akiran/react-highlight",
"dependencies": {
"highlight.js": "^9.11.0",
"react": "^15.5.4"
"highlight.js": "^9.11.0"
},
"devDependencies": {
"autoprefixer": "^6.7.7",
Expand All @@ -38,6 +37,7 @@
"babel-loader": "^7.1.2",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-react-jsx": "^6.24.1",
"babel-preset-env": "^1.6.0",
"es5-shim": "^4.5.9",
"eslint": "^3.19.0",
"eslint-plugin-react": "^6.10.3",
Expand All @@ -55,7 +55,13 @@
"node-libs-browser": "^2.0.0",
"phantomjs-prebuilt": "^2.1.14",
"raw-loader": "^0.5.1",
"webpack": "^1.15.0",
"webpack-dev-server": "^1.16.3"
"react": "^15.5.4",
"react-dom": "^15.5.4",
"webpack": "^3.6.0",
"webpack-dev-server": "^2.9.1"
},
"peerDependencies": {
"react": "^15.0.0 || ^16.0.0",
"react-dom": "^15.0.0 || ^16.0.0"
}
}
5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ class Highlight extends React.Component {

highlightCode() {
const nodes = this.el.querySelectorAll('pre code');
nodes.forEach((node) => hljs.highlightBlock(node));

for (let i = 0; i < nodes.length; i++) {
hljs.highlightBlock(nodes[i])
}
}

setEl = (el) => {
Expand Down
4 changes: 3 additions & 1 deletion src/optimized.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ class Highlight extends React.Component {
hljs.registerLanguage(lang, require('highlight.js/lib/languages/' + lang));
});

nodes.forEach((node) => hljs.highlightBlock(node));
for (let i = 0; i < nodes.length; i++) {
hljs.highlightBlock(nodes[i])
}
}

setEl = (el) => {
Expand Down

0 comments on commit 12d67cf

Please sign in to comment.