Safari 10中的新输入占位符行为 - 不再通过JavaScript隐藏更改 [英] New input placeholder behavior in Safari 10 - no longer hides on change via JavaScript

查看:251
本文介绍了Safari 10中的新输入占位符行为 - 不再通过JavaScript隐藏更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

macOS Sierra中的Safari 10.0似乎改变了输入占位符在输入值通过JavaScript更改时的行为方式。它现在也与Chrome(53.0.2785.116)所做的不同。



到目前为止,通过JavaScript设置输入值时,占位符会消失。



现在,通过JavaScript设置输入值不会隐藏占位符,直到输入获得焦点后(例如通过点击)。

查看JS Bin的演示: https://jsbin.com/rogoludahu/edit?html,js,output



这是预期的行为吗?如果是这样,是否有一个聪明的解决方法,通过JavaScript更改后隐藏/取消隐藏占位符?

编辑:现在已经在rdar:// 28412751上提交了Safari 10和Safari技术预览版。


Safari 10.0 in macOS Sierra seems to have changed the way the placeholder in an input behaves when the input value is changed via JavaScript. It now also differs from what Chrome (53.0.2785.116) is doing.

Until now, when setting an input value via JavaScript the placeholder would disappear. After setting the value back to empty via JavaScript, the placeholder would reappear.

Now, setting the input value via JavaScript does not hide the placeholder, until the input gains focus afterwards (e.g. by being clicked on).

Check this JS Bin for a demo: https://jsbin.com/rogoludahu/edit?html,js,output

Is this the intended behavior? If so, is there a clever workaround for hiding/unhiding the placeholder after a change via JavaScript?

Edit: This has now been filed at rdar://28412751 for Safari 10 and the Safari Technology Preview.

解决方案

This has been resolved in Safari Technology Preview Release 37 (Safari 11.1, WebKit 12605.1.2) as well as in regular Safari Version 11.0.3 (WebKit 13604.5.6).

这篇关于Safari 10中的新输入占位符行为 - 不再通过JavaScript隐藏更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆