diff --git a/htmlfills.js b/htmlfills.js
index 1587b45..6979131 100644
--- a/htmlfills.js
+++ b/htmlfills.js
@@ -70,7 +70,8 @@ document.addEventListener('DOMContentLoaded', function () {
var polyfills = {
dialog: {
supports: 'HTMLDialogElement' in window,
- js: 'https://cdn.jsdelivr.net/npm/dialog-polyfill@0.5.6/dist/dialog-polyfill.min.js',
+ js: 'https://cdn.jsdelivr.net/gh/nuxodin/dialog-polyfill@0.5.7/dist/dialog-polyfill.min.js',
+ //js: 'https://cdn.jsdelivr.net/npm/dialog-polyfill@0.5.6/dist/dialog-polyfill.min.js',
//css: 'https://cdn.jsdelivr.net/npm/dialog-polyfill@0.5.6/dialog-polyfill.css',
onfound: function(el){
dialogPolyfill.registerDialog(el);
@@ -114,4 +115,4 @@ function loadScript(path, cb, eb) {
-}(window, document);
+}(window, document);
\ No newline at end of file
diff --git a/mod.js b/mod.js
index 429e084..3f1d24d 100644
--- a/mod.js
+++ b/mod.js
@@ -54,14 +54,14 @@ addCombo('cdn.jsdelivr.net/gh/nuxodin/lazyfill@0.5.0/polyfills/Element/combo.js'
remove:1,
blur:1, // to use in SVGElement:
focus:1,
- contains:1,
+// contains:1, // moved to Node.prototype
classList:1,
getElementsByClassName:1,
children:1,
}, Element.prototype);
/* blank object "CSS" needed */
-if (!window.CSS) CSS = {};
+if (!window.CSS) window.CSS = {};
var lazyfills = {
Array:{
from:1,
@@ -90,8 +90,16 @@ var lazyfills = {
currentScript:1,
caretRangeFromPoint:1,
},
+ Node:{
+ prototype:{
+ contains:1,
+ isConnected:1,
+ },
+ },
Element:{
- toggleAttribute:1
+ prototype:{
+ toggleAttribute:1
+ }
},
HTMLFormElement:{
prototype:{
@@ -237,6 +245,30 @@ function loadScriptSync(path) {
}
}
+
+/*
+if (!('contains' in Node.prototype)) {
+ Node.prototype.contains = function(el){
+ if (el instanceof CharacterData) {
+ if (!el.parentNode) return false;
+ el = el.parentNode;
+ }
+ if (this === el) return true;
+ if (this instanceof Document) {
+ return this.documentElement.contains(el)
+ }
+ return HTMLElement.prototype.contains.call(this, el);
+ }
+}
+if (!('isConnected' in Node.prototype)) {
+ Object.defineProperty(Node.prototype, 'isConnected',{
+ get:function(){
+ return this.ownerDocument.contains(this);
+ }
+ })
+}
+*/
+
/* very small polyfills, they are not worth adding to the service */
if (!NodeList.prototype.forEach) NodeList.prototype.forEach = Array.prototype.forEach; // ie11
if (!document.scrollingElement) document.scrollingElement = document.documentElement; // ie11
diff --git a/polyfills/Element/combo.js b/polyfills/Element/combo.js
index ffe4b8b..0a7a451 100644
--- a/polyfills/Element/combo.js
+++ b/polyfills/Element/combo.js
@@ -56,7 +56,7 @@ function mutationMacro(nodes) {
var props = [
'blur', // ie11
'focus',
- 'contains',
+// 'contains', // needed at Node.prototype
'classList',
'getElementsByClassName',
// 'className',
diff --git a/polyfills/Node/prototype/contains.js b/polyfills/Node/prototype/contains.js
new file mode 100644
index 0000000..71c8a12
--- /dev/null
+++ b/polyfills/Node/prototype/contains.js
@@ -0,0 +1,13 @@
+if (!('contains' in Node.prototype)) {
+ Node.prototype.contains = function(el){
+ if (el instanceof CharacterData) {
+ if (!el.parentNode) return false;
+ el = el.parentNode;
+ }
+ if (this === el) return true;
+ if (this instanceof Document) {
+ return this.documentElement.contains(el)
+ }
+ return HTMLElement.prototype.contains.call(this, el);
+ }
+}
diff --git a/polyfills/Node/prototype/isConnected.js b/polyfills/Node/prototype/isConnected.js
new file mode 100644
index 0000000..4c66ae2
--- /dev/null
+++ b/polyfills/Node/prototype/isConnected.js
@@ -0,0 +1,7 @@
+if (!('isConnected' in Node.prototype)) {
+ Object.defineProperty(Node.prototype, 'isConnected',{
+ get:function(){
+ return this.ownerDocument.contains(this);
+ }
+ })
+}
diff --git a/test.html b/test.html
index c6573d1..2dfbac0 100644
--- a/test.html
+++ b/test.html
@@ -33,7 +33,39 @@
console.log(korean.hourCycle, japanese.hourCycle);
// expected output: "h24" "h12"
-}, 1000)
+}, 1000);
+
+
+/* Node contains tests */
+
+console.log(
+ 'document.contains(document)',
+ document.contains(document)
+)
+console.log(
+ 'document.documentElement.contains(document)',
+ document.documentElement.contains(document)
+)
+console.log(
+ 'document.contains(document.documentElement)',
+ document.contains(document.documentElement)
+)
+console.log(
+ 'document.documentElement.contains(document.documentElement)',
+ document.documentElement.contains(document.documentElement)
+)
+var textel = document.body.firstChild;
+console.log(
+ 'document.contains(textel)',
+ document.contains(textel)
+)
+
+/* is connected tests */
+
+div = document.createElement('div');
+console.log(div.isConnected);
+document.body.append(div)
+console.log(div.isConnected);