Comments (5)
what if you remove that child on oload? The registration of elements might be asynchronous if the readyState
is not complete. This seems like a won't fix to me, also because IE8 support is experimental and this case doesn't look like a real-world one.
Last, but not least, I will not accept any other bug with such poor description.
from document-register-element.
thank u :) , and say sorry for my poor english.
and, i found in IE9, the detachCallback
will call twice if i have two <x-a>
in DOM but i only remove the node with id(only one)? or more
<!DOCTYPE html>
<html>
<head>
<title>Modern DOM</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0,minimal-ui">
<script src="build/document-register-element.max.js"></script>
</head>
<body>
<x-a id="xx" style="background:red;height:100px;display:block;"/>
<x-a></x-a>
<script>
var MyElement = document.registerElement(
'x-a',
{
prototype: Object.create(
HTMLElement.prototype, {
detachedCallback: {value: function() {
console.log('leaving the DOM :-( )');
}}
})
}
);
</script>
<script>
var el = document.getElementById('xx');
document.body.removeChild(el);
</script>
</body>
</html>
I found the code
function executeAction(action) {
return function (node) {
if (isValidNode(node)) {
verifyAndSetupAndAction(node, action);
loopAndVerify(
node.querySelectorAll(query),
action
);
}
};
}
node.querySelectorAll(query)
has some problem when removeChild,it will get all x-a element, no current node that be removed.
and then
function verifyAndSetupAndAction(node, action) {
var
fn,
i = getTypeIndex(node)
;
if (-1 < i) {
patchIfNotAlready(node, protos[i]);
i = 0;
if (action === ATTACHED && !node[ATTACHED]) {
node[DETACHED] = false;
node[ATTACHED] = true;
i = 1;
if (IE8 && indexOf.call(targets, node) < 0) {
targets.push(node);
}
} else if (action === DETACHED && !node[DETACHED]) {
node[ATTACHED] = false;
node[DETACHED] = true;
i = 1;
}
if (i && (fn = node[action + 'Callback'])) fn.call(node);
}
}
the code if (i && (fn = node[action + 'Callback'])) fn.call(node);
execute every time
from document-register-element.
can you pleasae try to remove whatever you want after the onload event?
from document-register-element.
sorry, same result
<script>
window.onload = function () {
var el = document.getElementById('xx');
document.body.removeChild(el);
};
</script>
even,
<script>
window.onload = function () {
setTimeout(function () {
var el = document.getElementById('xx');
document.body.removeChild(el);
}, 1000);
};
</script>
please try it, maybe i was wrong, thank u
from document-register-element.
very very sorry it's my wrong~
i found the first <x-a>
is a self-close tag, so has this wrong result
<x-a id="xx "/>
must be
<x-a id="xx"></x-a>
from document-register-element.
Related Issues (20)
- LifeCycle events order of nested custom elements inconsistent across Chrome and Firefox HOT 18
- Built-in elements don't work in Firefox HOT 6
- TypeError: new.target does not define a custom element HOT 3
- document.registerElement is deprecated and will be removed in M73 HOT 3
- Post-install script slowness HOT 3
- appreciate your feedback for custom element diagram HOT 8
- [Uncaught DOMException: Failed to execute 'registerElement' on 'Document'] when used in Chrome Extension HOT 16
- Functions are not evaluated in connectedCallback HOT 1
- `this` reference in contructor broken HOT 14
- Multiple instances of the polyfill leads to unexpected behaviour HOT 1
- error ""Failed to construct 'HTMLElement': Please use the 'new' operator"" when using with Angular/elements 8.2.0 HOT 2
- Refreshing a document inside an iframe which loads d-r-e breaks the polyfill and leaves document.createElement as undefined HOT 15
- `attributeChangedCallback()` bound value is invalid HOT 15
- Add DRE to Polyfill.io service HOT 1
- [QUESTION] Unable to get property '_isMounted' of undefiened. HOT 1
- TypeError - Object doesn't support property or method 'registerElement' HOT 3
- Time to compare again? (webcompents/custom-elements) HOT 2
- Polyfill does not seem to be working in IE 11 HOT 6
- postinstall fails in noexec enviornment HOT 1
- We unable to install latest version @1.14.7 HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from document-register-element.