语法高亮,滚动条美化,设置页面调整

This commit is contained in:
fofolee
2019-04-19 02:41:09 +08:00
parent 1e8f76c000
commit 359d29ee0b
1590 changed files with 12328 additions and 11441 deletions

View File

@@ -27,7 +27,7 @@
<p>你不能直接更改这个属性,它是只读的。</p>
<h2 id="例子">例子</h2>
<h3 id="使用带_sticky_标志的正则表达式">使用带 sticky 标志的正则表达式</h3>
<pre class="brush: js">var str = '#foo#';
<pre><code class="language-javascript">var str = '#foo#';
var regex = /foo/y;
regex.lastIndex = 1;
@@ -35,14 +35,14 @@ regex.test(str); // true (译注:此例仅当 lastIndex = 1 时匹配成功
regex.lastIndex = 5;
regex.test(str); // false lastIndex 被 sticky 标志考虑到,从而导致匹配失败)
regex.lastIndex; // 0 (匹配失败后重置)
</pre>
</code></pre>
<h3 id="锚定的_sticky_标志">锚定的 sticky 标志</h3>
<p>火狐的 SpiderMonkey 引擎的几个版本有一个 <a class="external" href="https://bugzilla.mozilla.org/show_bug.cgi?id=773687" rel="noopener">bug</a>,处理 <code>^</code> 断言和 sticky 标志时,会允许使用了 sticky 标志的表达式从 <code>^</code> 断言开始匹配,这是不应该的。这个 bug 是在 Firefox 3.6 之后的某个版本引入的which had the sticky flag but not the bug并于2015年修复。 可能正因为这个 bug ES2015 规范 <a class="external" href="http://www.ecma-international.org/ecma-262/7.0/index.html#sec-assertion" rel="noopener">特别指出</a></p>
<blockquote>
<p>当使用带有y标识的匹配模式时^断言总是会匹配输入的开始位置或者(如果是多行模式)每一行的开始位置。</p>
</blockquote>
<p>正确行为的示例:</p>
<pre class="brush: js">var regex = /^foo/y;
<pre><code class="language-javascript">var regex = /^foo/y;
regex.lastIndex = 2;
regex.test("..foo"); // false - 索引2不是字符串的开始
@@ -51,7 +51,7 @@ regex2.lastIndex = 2;
regex2.test("..foo"); // false - 索引2不是字符串或行的开始
regex2.lastIndex = 2;
regex2.test(".\nfoo"); // true - 索引2是行的开始
</pre>
</code></pre>
<h2 id="规范">规范</h2>
<table class="standard-table">
<tbody>