Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
projects.thm.de
GitLab
Commits
ff71ac72
Commit
ff71ac72
authored
Feb 12, 2019
by
Brett Walker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Find checkbox input with less specific selector
parent
a58e92fc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
7 deletions
+27
-7
app/services/task_list_toggle_service.rb
app/services/task_list_toggle_service.rb
+1
-1
spec/services/task_list_toggle_service_spec.rb
spec/services/task_list_toggle_service_spec.rb
+26
-6
No files found.
app/services/task_list_toggle_service.rb
View file @
ff71ac72
...
@@ -67,6 +67,6 @@ def toggle_markdown_html
...
@@ -67,6 +67,6 @@ def toggle_markdown_html
# When using CommonMark, we should be able to use the embedded `sourcepos` attribute to
# When using CommonMark, we should be able to use the embedded `sourcepos` attribute to
# target the exact line in the DOM.
# target the exact line in the DOM.
def
get_html_checkbox
(
html
)
def
get_html_checkbox
(
html
)
html
.
css
(
".task-list-item[data-sourcepos^='
#{
line_number
}
:']
>
input.task-list-item-checkbox"
).
first
html
.
css
(
".task-list-item[data-sourcepos^='
#{
line_number
}
:'] input.task-list-item-checkbox"
).
first
end
end
end
end
spec/services/task_list_toggle_service_spec.rb
View file @
ff71ac72
...
@@ -12,6 +12,10 @@
...
@@ -12,6 +12,10 @@
1. [X] Item 1
1. [X] Item 1
- [ ] Sub-item 1
- [ ] Sub-item 1
- [ ] loose list
with an embedded paragraph
EOT
EOT
end
end
...
@@ -26,16 +30,22 @@
...
@@ -26,16 +30,22 @@
</li>
</li>
</ul>
</ul>
<p data-sourcepos="4:1-4:11" dir="auto">A paragraph</p>
<p data-sourcepos="4:1-4:11" dir="auto">A paragraph</p>
<ol data-sourcepos="6:1-
7:19
" class="task-list" dir="auto">
<ol data-sourcepos="6:1-
8:0
" class="task-list" dir="auto">
<li data-sourcepos="6:1-
7:19
" class="task-list-item">
<li data-sourcepos="6:1-
8:0
" class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox"
disabled checked
> Item 1
<input type="checkbox" class="task-list-item-checkbox"
checked="" disabled=""
> Item 1
<ul data-sourcepos="7:4-
7:19
" class="task-list">
<ul data-sourcepos="7:4-
8:0
" class="task-list">
<li data-sourcepos="7:4-
7:19
" class="task-list-item">
<li data-sourcepos="7:4-
8:0
" class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled> Sub-item 1
<input type="checkbox" class="task-list-item-checkbox" disabled
=""
> Sub-item 1
</li>
</li>
</ul>
</ul>
</li>
</li>
</ol>
</ol>
<ul data-sourcepos="9:1-11:28" class="task-list" dir="auto">
<li data-sourcepos="9:1-11:28" class="task-list-item">
<p data-sourcepos="9:3-9:16"><input type="checkbox" class="task-list-item-checkbox" disabled=""> loose list</p>
<p data-sourcepos="11:3-11:28">with an embedded paragraph</p>
</li>
</ul>
EOT
EOT
end
end
...
@@ -59,6 +69,16 @@
...
@@ -59,6 +69,16 @@
expect
(
toggler
.
updated_markdown_html
).
to
include
(
'disabled> Item 1'
)
expect
(
toggler
.
updated_markdown_html
).
to
include
(
'disabled> Item 1'
)
end
end
it
'checks task in loose list'
do
toggler
=
described_class
.
new
(
markdown
,
markdown_html
,
toggle_as_checked:
true
,
line_source:
'- [ ] loose list'
,
line_number:
9
)
expect
(
toggler
.
execute
).
to
be_truthy
expect
(
toggler
.
updated_markdown
.
lines
[
8
]).
to
eq
"- [x] loose list
\n
"
expect
(
toggler
.
updated_markdown_html
).
to
include
(
'disabled checked> loose list'
)
end
it
'returns false if line_source does not match the text'
do
it
'returns false if line_source does not match the text'
do
toggler
=
described_class
.
new
(
markdown
,
markdown_html
,
toggler
=
described_class
.
new
(
markdown
,
markdown_html
,
toggle_as_checked:
false
,
toggle_as_checked:
false
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment