Skip to content

Commit 2add03c

Browse files
geophreemarijnh
authored andcommitted
[html-line addon] Play more nicely with node/webpack.
* Pass in and use the htmlhint module required. * Check for verify() and try HTMLHint.HTMLHint if missing because of module nesting. it's require('htmlhint').HTMLHint in node.
1 parent 974b698 commit 2add03c

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

addon/lint/html-lint.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
else if (typeof define == "function" && define.amd) // AMD
1212
define(["../../lib/codemirror", "htmlhint"], mod);
1313
else // Plain browser env
14-
mod(CodeMirror);
15-
})(function(CodeMirror) {
14+
mod(CodeMirror, window.HTMLHint);
15+
})(function(CodeMirror, HTMLHint) {
1616
"use strict";
1717

1818
var defaultRules = {
@@ -29,9 +29,11 @@
2929

3030
CodeMirror.registerHelper("lint", "html", function(text, options) {
3131
var found = [];
32-
if (!window.HTMLHint) {
32+
if (HTMLHint && !HTMLHint.verify) HTMLHint = HTMLHint.HTMLHint;
33+
if (!HTMLHint) HTMLHint = window.HTMLHint;
34+
if (!HTMLHint) {
3335
if (window.console) {
34-
window.console.error("Error: window.HTMLHint not defined, CodeMirror HTML linting cannot run.");
36+
window.console.error("Error: HTMLHint not found, not defined on window, or not available through define/require, CodeMirror HTML linting cannot run.");
3537
}
3638
return found;
3739
}

0 commit comments

Comments
 (0)