Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit 0eb9830

Browse files
authored
Merge pull request #62 from shinsenter/develop
Fixed custom_splash_screen bugs
2 parents 57c50e2 + af02848 commit 0eb9830

File tree

8 files changed

+51
-29
lines changed

8 files changed

+51
-29
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,16 +260,17 @@ $options = [
260260
// Default: blank array
261261
'ignore_lazyload_texts' => [],
262262

263-
// Do not lazy-load for tags containing
264-
// one of these CSS class names.
263+
// Do not lazy-load for tags containing one of these CSS class names.
265264
// Default: blank array
266265
'ignore_lazyload_css_class' => [],
267266

268-
// Do not lazy-load for tags containing
269-
// one of these CSS selectors.
267+
// Do not lazy-load for tags matching one of these CSS selectors.
270268
// See: https://www.w3schools.com/cssref/css_selectors.asp
271269
// Default: blank array
272-
'ignore_lazyload_css_selectors' => [],
270+
'ignore_lazyload_css_selectors' => [
271+
// 'header img',
272+
// 'img#logo',
273+
],
273274
];
274275

275276
// Create a Defer object

composer.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"author": "Mai Nhut Tan <[email protected]>",
44
"license": "MIT",
55
"dependencies": {
6-
"@shinsenter/defer.js": "^2.4.0"
6+
"@shinsenter/defer.js": "^2.4.1"
77
},
88
"scripts": {
99
"cleanup": "rm -rf ./node_modules package-lock.json",

public/lib/defer.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.

public/lib/defer_plus.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.

src/Elements/CommonDomTraits.php

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public function precede($input)
189189

190190
if ($this->parentNode instanceof DOMNode) {
191191
foreach ($input as $node) {
192-
$this->parentNode->insertBefore($node, $this);
192+
$this->parentNode->insertBefore($this->_safeNode($node), $this);
193193
}
194194
}
195195
}
@@ -211,6 +211,8 @@ public function follow($input)
211211

212212
if ($this->parentNode instanceof DOMNode) {
213213
foreach ($input as $node) {
214+
$node = $this->_safeNode($node);
215+
214216
if (is_null($this->nextSibling)) {
215217
$this->parentNode->appendChild($node);
216218
} else {
@@ -236,7 +238,7 @@ public function prependWith($input)
236238
}
237239

238240
foreach ($input as $node) {
239-
$this->insertBefore($node, $this->firstChild);
241+
$this->insertBefore($this->_safeNode($node), $this->firstChild);
240242
}
241243
}
242244

@@ -256,7 +258,7 @@ public function appendWith($input)
256258
}
257259

258260
foreach ($input as $node) {
259-
$this->appendChild($node);
261+
$this->appendChild($this->_safeNode($node));
260262
}
261263
}
262264

@@ -310,4 +312,22 @@ private function _pushAttrValue($name, $value, $addValue = false)
310312
}
311313
}
312314
}
315+
316+
/**
317+
* @internal
318+
*
319+
* @param \DOMNode|string $input
320+
* @return \DOMNode
321+
*/
322+
private function _safeNode($input)
323+
{
324+
if ($input instanceof DOMNode) {
325+
return $input;
326+
}
327+
328+
$fragment = $this->document()->createDocumentFragment();
329+
$fragment->appendXML($input);
330+
331+
return $fragment;
332+
}
313333
}

src/Helpers/DeferOptions.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -376,16 +376,17 @@ public function getWellKnown3rd($useCache = true)
376376
* // Default: blank array
377377
* 'ignore_lazyload_texts' => [],
378378
*
379-
* // Do not lazy-load for tags containing
380-
* // one of these CSS class names.
379+
* // Do not lazy-load for tags containing one of these CSS class names.
381380
* // Default: blank array
382381
* 'ignore_lazyload_css_class' => [],
383382
*
384-
* // Do not lazy-load for tags containing
385-
* // one of these CSS selectors.
383+
* // Do not lazy-load for tags matching one of these CSS selectors.
386384
* // See: https://www.w3schools.com/cssref/css_selectors.asp
387385
* // Default: blank array
388-
* 'ignore_lazyload_css_selectors' => [],
386+
* 'ignore_lazyload_css_selectors' => [
387+
* // 'header img',
388+
* // 'img#logo',
389+
* ],
389390
*
390391
* @since 2.0.0
391392
* @return array

0 commit comments

Comments
 (0)