Fix starts-with() for JRuby 1.7

''.start_with?('') returns false on JRuby 1.7. While I'd love to drop
support for shit like this, JRuby 1.7 is still in common use today, so
lets just work around this for now.
This commit is contained in:
Yorick Peterse 2015-08-30 02:10:49 +02:00
parent bf0ca7c907
commit 67ada1168e
1 changed files with 9 additions and 3 deletions

View File

@ -1032,10 +1032,16 @@ module Oga
needle_var.assign(try_match_first_node(needle, input))
end
.followed_by do
converted = conversion.to_string(haystack_var)
.start_with?(conversion.to_string(needle_var))
haystack_var.assign(conversion.to_string(haystack_var))
.followed_by do
needle_var.assign(conversion.to_string(needle_var))
end
.followed_by do
equal = needle_var.empty?
.or(haystack_var.start_with?(needle_var))
block_given? ? converted.if_true { yield } : converted
block_given? ? equal.if_true { yield } : equal
end
end
end