diff options
author | Douwe Maan <douwe@gitlab.com> | 2016-01-07 14:04:01 +0100 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2016-01-07 15:52:34 +0100 |
commit | c3865bda0257506e3e9ba8352913eb288f0e3e34 (patch) | |
tree | 8f04f0c2a5f9b93ded6cc2dc7a5839560bd33e56 /lib/banzai | |
parent | 09216e8bbdd82e46705888aba13405a2fd191100 (diff) | |
download | gitlab-ce-c3865bda0257506e3e9ba8352913eb288f0e3e34.tar.gz |
Properly set task-list class on single item task lists
Diffstat (limited to 'lib/banzai')
-rw-r--r-- | lib/banzai/filter/task_list_filter.rb | 13 |
1 files changed, 9 insertions, 4 deletions
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 |