Skip to content

Commit 25e5207

Browse files
committed
Fix issue with <select> nodes
Whenever options get removed, other options gets selected. This is problematic in some case, but luckily that does not happen when the select insertBefore option nodes. This change reduce a bit overall code size, and it might improve performance in most common cases/browsers. It also fixes a nasty issue in lighterhtml: WebReflection/lighterhtml#50
1 parent a66d5dd commit 25e5207

File tree

4 files changed

+7
-22
lines changed

4 files changed

+7
-22
lines changed

cjs/utils.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,8 @@
22
const Map = (require('@ungap/essential-map'));
33

44
const append = (get, parent, children, start, end, before) => {
5-
if ((end - start) < 2)
6-
parent.insertBefore(get(children[start], 1), before);
7-
else {
8-
const fragment = parent.ownerDocument.createDocumentFragment();
9-
while (start < end)
10-
fragment.appendChild(get(children[start++], 1));
11-
parent.insertBefore(fragment, before);
12-
}
5+
while (start < end)
6+
parent.insertBefore(get(children[start++], 1), before);
137
};
148
exports.append = append;
159

esm/utils.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
import Map from '@ungap/essential-map';
22

33
export const append = (get, parent, children, start, end, before) => {
4-
if ((end - start) < 2)
5-
parent.insertBefore(get(children[start], 1), before);
6-
else {
7-
const fragment = parent.ownerDocument.createDocumentFragment();
8-
while (start < end)
9-
fragment.appendChild(get(children[start++], 1));
10-
parent.insertBefore(fragment, before);
11-
}
4+
while (start < end)
5+
parent.insertBefore(get(children[start++], 1), before);
126
};
137

148
export const eqeq = (a, b) => a == b;

index.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,8 @@ try {
3939
var Map$1 = self.Map;
4040

4141
var append = function append(get, parent, children, start, end, before) {
42-
if (end - start < 2) parent.insertBefore(get(children[start], 1), before);else {
43-
var fragment = parent.ownerDocument.createDocumentFragment();
44-
while (start < end) {
45-
fragment.appendChild(get(children[start++], 1));
46-
}parent.insertBefore(fragment, before);
42+
while (start < end) {
43+
parent.insertBefore(get(children[start++], 1), before);
4744
}
4845
};
4946

min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)