summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2016-01-07 14:04:01 +0100
committerDouwe Maan <douwe@gitlab.com>2016-01-07 15:52:34 +0100
commitc3865bda0257506e3e9ba8352913eb288f0e3e34 (patch)
tree8f04f0c2a5f9b93ded6cc2dc7a5839560bd33e56
parent09216e8bbdd82e46705888aba13405a2fd191100 (diff)
downloadgitlab-ce-c3865bda0257506e3e9ba8352913eb288f0e3e34.tar.gz
Properly set task-list class on single item task lists
-rw-r--r--CHANGELOG1
-rw-r--r--lib/banzai/filter/task_list_filter.rb13
2 files changed, 10 insertions, 4 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 22fb91baaf0..c034344e7f9 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -21,6 +21,7 @@ v 8.4.0 (unreleased)
- Update version check images to use SVG
- Validate README format before displaying
- Enable Microsoft Azure OAuth2 support (Janis Meybohm)
+ - Properly set task-list class on single item task lists
v 8.3.3 (unreleased)
- Get "Merge when build succeeds" to work when commits were pushed to MR target branch while builds were running
diff --git a/lib/banzai/filter/task_list_filter.rb b/lib/banzai/filter/task_list_filter.rb
index bdf7c2ebdfc..d0ce13003a5 100644
--- a/lib/banzai/filter/task_list_filter.rb
+++ b/lib/banzai/filter/task_list_filter.rb
@@ -12,13 +12,18 @@ module Banzai
#
# See https://github.com/github/task_list/pull/60
class TaskListFilter < TaskList::Filter
- def add_css_class(node, *new_class_names)
+ def add_css_class_with_fix(node, *new_class_names)
if new_class_names.include?('task-list')
- super if node.children.any? { |c| c['class'] == 'task-list-item' }
- else
- super
+ # Don't add class to all lists
+ return
+ elsif new_class_names.include?('task-list-item')
+ add_css_class_without_fix(node.parent, 'task-list')
end
+
+ add_css_class_without_fix(node, *new_class_names)
end
+
+ alias_method_chain :add_css_class, :fix
end
end
end