diff options
author | Robert Speicher <robert@gitlab.com> | 2016-01-07 23:10:07 +0300 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2016-01-07 23:10:07 +0300 |
commit | b1539116f65c302729ca4130a30169295dcfc07e (patch) | |
tree | 91320986bc27e64414b854b7a92c706bccccc5e3 /lib | |
parent | 87000b25f58c160ed16fc7c8fcf131ef39c3955c (diff) | |
parent | 79938744a857874692439c7381e7ef62b5023b0e (diff) |
Merge branch 'task-list-class' into 'master'
Properly set task-list class on single item task lists
Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/4193
See merge request !2330
Diffstat (limited to 'lib')
-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 |