首页 \ 问答 \ html标记中的Javascript事件(Javascript events in html tag)

html标记中的Javascript事件(Javascript events in html tag)

在网页中包含JavaScript时,为什么通常认为使用各种内联事件属性是不好的形式

(such as onclick, onsubmit,etc) in HTML tags? (eg <div onclick="dostuff()">Click Me</div>)


When including JavaScript in a web page, why is it generally considered poor form to use the various inline event attributes

(such as onclick, onsubmit,etc) in HTML tags? (e.g. <div onclick="dostuff()">Click Me</div>)


原文:https://stackoverflow.com/questions/26415287
更新时间:2022-05-23 06:05

最满意答案

Count是PHP的内部函数,在您的场景中不会被模拟。 你模拟了对count的getMapper()调用( getMapper->Count() )。 对于您的测试,只需模拟$this->getMapper("fulltext")->find()并返回任何内容,因此PHP count()将等于0。


Turns out that I have been over-relying on autoload behaviour in the Zend implementation of PHPUnit, and fell foul of a change in PHPUnit's mock objects.

In this specific case, the class being mocked wasn't being autoloaded due to limits in Zend/PHPUnit and autoloading (the test is not bootstrapping the whole application - nor should it, since this supposed to be a unit test) - this used to cause a "class not found" error in PHPUnit 3.4, but the new PHPUnit 4.x implementation will fabricate a stub class. The stub class did not implement any interfaces, so the PHP count() built-in did not know the object was Countable.

I've now required the specific source file for the class being mocked, and the mock (and PHP count() built-in) is behaving exactly as I'd expect.

相关问答

更多
  • 看看VirtualPathProvider.Previous属性。 MSDN表示Previous属性获取对编译系统中先前注册的VirtualPathProvider对象的引用。 所以你应该修改一下你的FileExists方法,如: Dim i As Integer = Convert.ToInt32(retval) If i <= 0 Then Return Previous.FileExists(virtualPath) Else Return True End If GetFile方法 ...
  • 你正在使用COUNT ,它同样很乐意将0 s计为1 s。 如果您希望COUNT忽略ELSE值,请使用NULL而不是0 : SELECT COUNT( CASE WHEN MyDate >= GETDATE() AND MyDate < DATEADD(DAY, 1, GETDATE()) THEN 1 ELSE NULL -- <== Change is here END) AS DatesNearlyOverd ...
  • Constraint类实现Countable 。 所需的count方法将返回评估约束时将添加到计数器的断言的数量: https://github.com/sebastianbergmann/phpunit/blob/5.7.26/src/Framework/Assert.php#L2056 您的约束count方法应该返回至少1 ,以便对断言进行计数。 检查它是否返回0 。 The Constraint class implements Countable. The required count method ...
  • Count是PHP的内部函数,在您的场景中不会被模拟。 你模拟了对count的getMapper()调用( getMapper->Count() )。 对于您的测试,只需模拟$this->getMapper("fulltext")->find()并返回任何内容,因此PHP count()将等于0。 Turns out that I have been over-relying on autoload behaviour in the Zend implementation of PHPUnit, and f ...
  • 尝试将过滤器发送到该功能。 Public Shared Function search(filters As String) As DataTable Dim dt As New DataTable Dim Str As String = _ SELECT * FROM Player INNER JOIN Report ON Report.PlayerID = ...
  • PowerShell脚本是从顶部到底部读取的,因此在定义之前不能使用任何引用,这很可能就是您接收错误的原因。 尝试在你调用它们的点上添加你的函数定义块。 或者,您可以创建一个具有全局范围的函数。 只需在关键字global的前面加上函数名: like, function global:test ($x, $y) { $x * $y } PowerShell Scripts are read from the top to the bottom, so you can't use any refer ...
  • 您的Nexus 4不是虚拟设备,因此不会在虚拟设备管理器中显示。 如果你打开设备视图,那么你应该看到你的Nexus 4列出了,当你运行你的应用程序时,它应该提示将它作为物理或虚拟设备运行。 Your Nexus 4 isn't a virtual device, so won't show in Virtual Devices Manager. If you open the Devices view, then you should see your Nexus 4 listed, and when yo ...
  • 我相信我们应该在这里考虑一些事情。 你使用的是什么版本的PHP。 并非所有版本的PHP都支持异常,名称空间也很重要,除非您使用的依赖管理器可能配置了其名称空间,但如果您是从头开始构建,则可能需要考虑命名空间和版本PHP I believe we should consider some things here. What version of PHP are you using. Not all version of PHP supports Exception and the namespaces doe ...
  • 以下测试使用PHPUnit 3.6.12在我的系统上传递。 class Foo { function bla() { $this->blub(); } function blub() { echo 'blub'; } } class FooTest extends PHPUnit_Framework_TestCase { function setUp() { $this->_testObject = $this->g ...
  • 使用正则表达式匹配行后£后面的任何文本,并用“5”替换所有“S”字符。 这假设您在货币符号后面只会有非字母字符(特别是没有S字符)。 这个正则表达式应该工作: £[0-9S]+\.[0-9S]{2} 从那里,找到你的S字符的索引,并用5替换它们。 在货币符号不存在(或检测到)的情况下,仅使用正则表达式来识别货币金额应该有效。 根据您的示例,我不希望在项目描述中找到该模式。 像这样的东西: \s+[0-9S]+\.[0-9S]{2} 或者如果货币符号是乱码,则通配符如下: \s+.[0-9S]+\.[0- ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)