我有一个input.onkeydown处理程序,我检查input.value后setTimeout(..0)。
我希望input.value在setTimeout回调运行时具有新值。
在除Firefox之外的所有浏览器中都可以。在Firefox中,情况并非总是如此。
要检查的代码是:
<input id="input">
<script>
input.onkeydown = function() {
setTimeout(() => this.value = this.value.toUpperCase());
};
</script>
Run Code Online (Sandbox Code Playgroud)
演示:http : //plnkr.co/edit/rZmiHdttSXNdpKkR8YbH?p=preview
由于我将after之后的输入值大写setTimeout(..0),因此应始终将其大写。但是如前所述,在Firefox中不是。
这是演示视频;前几秒钟演示了该问题:https : //jmp.sh/9XSROQ2
相关规范部分是https://dom.spec.whatwg.org/#concept-event-dispatch。
我没有得到任何东西,或者这是Firefox中的长期错误?
PS如果我添加console.log的setTimeout,我有时会看到旧值。
PPS这个问题的目的是要知道我setTimeout是否正确理解。我熟悉各种大写方式input; 请不要暗示oninput,requestAnimationFrame或者这样的。
让我说我有
home.styl
menu/
menu.styl
image.svg
home.styl 从入口点或JS需要.
然后:
home.styl进口menu/menu.styl
menu/menu.styl有url(image.svg).
问题是image.svg找不到.
它存在于同一文件夹中menu.styl,但未解析.
装载机是:
loaders: [{
test: /\.styl$/,
loader: 'style!css!stylus'
}, {
test: /\.(png|jpg|svg|ttf|eot|woff|woff2)$/,
loader: 'file?name=[path][name].[ext]'
}]
以下是我的想法,为什么失败.希望得到如何解决这个问题的答案.
===========
如果url(image.svg)需要menu.styl,应该在文件夹中查找menu.styl.那是因为路径默认是相对的.
但是发生的事情如下:
styl,将导入加入一个大的csscss根上下文,即目录home.stylurl(...)相对于上层上下文的所有路径.因此,在文件夹中搜索图像home.styl而不是menu.styl.
如何解决?