aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jesse Hallett <jesse@galois.com>2014-01-07 16:30:55 -0800
committerGravatar Jesse Hallett <jesse@galois.com>2014-01-07 16:31:25 -0800
commit9bdbf90830b0cae75484565e840655117b66a87b (patch)
treefaa04a73b4e9e10a24e55fb63d781dad48283f90
parentbb7a486e5876d9bd3c4bf8a18f45a30baf5f8fe5 (diff)
Modifies 'reflist' exception to inlineStyle rule
-rw-r--r--guidelines/wikipedia/specs/inlineStyle_spec.js21
-rw-r--r--guidelines/wikipedia/src/inlineStyle.js3
2 files changed, 23 insertions, 1 deletions
diff --git a/guidelines/wikipedia/specs/inlineStyle_spec.js b/guidelines/wikipedia/specs/inlineStyle_spec.js
new file mode 100644
index 0000000..d41969c
--- /dev/null
+++ b/guidelines/wikipedia/specs/inlineStyle_spec.js
@@ -0,0 +1,21 @@
+describe('inlineStyle', function() {
+ var inline = rule('Do not use in-line styles');
+
+ afterEach(teardownFixtures);
+
+ it('reports error for elements with style attribute', function() {
+ var $p = fixture('<p style="color:darkgoldenrod">fancy text</p>');
+ var results = run(inline);
+ expect(results.errors.length).toEqual(1);
+ expect(results.errors[0].element).toEqual($p.get(0));
+ });
+
+ it('excludes reflist list-style-type from report', function() {
+ var $l = fixture(
+ '<div class="reflist" style="list-style-type: decimal;">references</div>'
+ );
+ var results = run(inline);
+ expect(results.errors.length).toEqual(0);
+ expect(results.warnings.length).toEqual(0);
+ });
+});
diff --git a/guidelines/wikipedia/src/inlineStyle.js b/guidelines/wikipedia/src/inlineStyle.js
index 261586d..342547a 100644
--- a/guidelines/wikipedia/src/inlineStyle.js
+++ b/guidelines/wikipedia/src/inlineStyle.js
@@ -9,6 +9,7 @@ exports.rule = function(report) {
function excludes(i, elem) {
var $elem = $(elem);
+ var style = $elem.attr('style');
// Ignore width rules.
var widthRule = everyStyle($elem, function(s) {
@@ -21,7 +22,7 @@ function excludes(i, elem) {
// The standard reference list template also seems to include some
// inline styles.
- var reference = $elem.hasClass('reflist references-column-width') ||
+ var reference = ($elem.hasClass('reflist') && style.match(/list-style-type\s*:\s*decimal/)) ||
$elem.hasClass('error') ||
($elem.is('.citation ~ * *') && !$.trim($elem.text())); // <span>&nbsp;</span>