Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
2ab8364b
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
2ab8364b
编写于
12月 09, 2019
作者:
R
Rafael França
提交者:
GitHub
12月 09, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #37916 from Edouard-chin/ec-fix-actionview-tag-option
Fix input value not properly applied:
上级
73e079a1
95bc8d0a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
33 addition
and
3 deletion
+33
-3
actionview/lib/action_view/helpers/tag_helper.rb
actionview/lib/action_view/helpers/tag_helper.rb
+3
-3
actionview/test/template/tag_helper_test.rb
actionview/test/template/tag_helper_test.rb
+30
-0
未找到文件。
actionview/lib/action_view/helpers/tag_helper.rb
浏览文件 @
2ab8364b
...
...
@@ -94,7 +94,7 @@ def boolean_tag_option(key)
def
tag_option
(
key
,
value
,
escape
)
case
value
when
Array
,
Hash
value
=
build_tag_values
(
value
)
value
=
build_tag_values
(
value
)
if
key
.
to_s
==
"class"
value
=
escape
?
safe_join
(
value
,
" "
)
:
value
.
join
(
" "
)
else
value
=
escape
?
ERB
::
Util
.
unwrapped_html_escape
(
value
)
:
value
.
to_s
...
...
@@ -109,14 +109,14 @@ def build_tag_values(*args)
args
.
each
do
|
tag_value
|
case
tag_value
when
String
tag_values
<<
tag_value
if
tag_value
.
present?
when
Hash
tag_value
.
each
do
|
key
,
val
|
tag_values
<<
key
if
val
end
when
Array
tag_values
<<
build_tag_values
(
*
tag_value
).
presence
else
tag_values
<<
tag_value
.
to_s
if
tag_value
.
present?
end
end
...
...
actionview/test/template/tag_helper_test.rb
浏览文件 @
2ab8364b
...
...
@@ -37,6 +37,24 @@ def test_tag_options
assert_match
(
/class="elsewhere"/
,
str
)
end
def
test_tag_options_with_array_of_numeric
str
=
tag
(
:input
,
value:
[
123
,
456
])
assert_equal
(
"<input value=
\"
123 456
\"
/>"
,
str
)
end
def
test_tag_options_with_array_of_random_objects
klass
=
Class
.
new
do
def
to_s
"hello"
end
end
str
=
tag
(
:input
,
value:
[
klass
.
new
])
assert_equal
(
"<input value=
\"
hello
\"
/>"
,
str
)
end
def
test_tag_options_rejects_nil_option
assert_equal
"<p />"
,
tag
(
"p"
,
ignored:
nil
)
end
...
...
@@ -262,6 +280,18 @@ def test_content_tag_with_conditional_hash_classes
str
=
content_tag
(
"p"
,
"limelight"
,
class:
[
"song"
,
{
foo:
false
}])
assert_equal
"<p class=
\"
song
\"
>limelight</p>"
,
str
str
=
content_tag
(
"p"
,
"limelight"
,
class:
[
1
,
2
,
3
])
assert_equal
"<p class=
\"
1 2 3
\"
>limelight</p>"
,
str
klass
=
Class
.
new
do
def
to_s
"1"
end
end
str
=
content_tag
(
"p"
,
"limelight"
,
class:
[
klass
.
new
])
assert_equal
"<p class=
\"
1
\"
>limelight</p>"
,
str
str
=
content_tag
(
"p"
,
"limelight"
,
class:
{
"song"
:
true
,
"play"
:
true
})
assert_equal
"<p class=
\"
song play
\"
>limelight</p>"
,
str
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录