{"action":"created","issue":{"url":"https://api.github.com/repos/webcomponents/webcomponentsjs/issues/297","labels_url":"https://api.github.com/repos/webcomponents/webcomponentsjs/issues/297/labels{/name}","comments_url":"https://api.github.com/repos/webcomponents/webcomponentsjs/issues/297/comments","events_url":"https://api.github.com/repos/webcomponents/webcomponentsjs/issues/297/events","html_url":"https://github.com/webcomponents/webcomponentsjs/issues/297","id":71796407,"number":297,"title":"Assertion Failure when using removeChild()","user":{"login":"bdkjones","id":926566,"avatar_url":"https://avatars.githubusercontent.com/u/926566?v=3","gravatar_id":"","url":"https://api.github.com/users/bdkjones","html_url":"https://github.com/bdkjones","followers_url":"https://api.github.com/users/bdkjones/followers","following_url":"https://api.github.com/users/bdkjones/following{/other_user}","gists_url":"https://api.github.com/users/bdkjones/gists{/gist_id}","starred_url":"https://api.github.com/users/bdkjones/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bdkjones/subscriptions","organizations_url":"https://api.github.com/users/bdkjones/orgs","repos_url":"https://api.github.com/users/bdkjones/repos","events_url":"https://api.github.com/users/bdkjones/events{/privacy}","received_events_url":"https://api.github.com/users/bdkjones/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-04-29T07:00:10Z","updated_at":"2015-04-29T15:50:26Z","closed_at":null,"body":"I have a `<link>` element named `oldLink` that is a child node of `<head>`. When I do the following:\r\n\r\n```\r\noldLink.parentNode.removeChild(oldLink);\r\n```\r\n\r\nI get this result in my console:\r\n\r\n![screen shot 2015-04-28 at 23 53 30](https://cloud.githubusercontent.com/assets/926566/7385913/4fedee48-ee02-11e4-9c5c-cd953514e085.png)\r\n\r\nRemoving webcomponents.js from the page solves the problem, as does switching to the `lite` version. \r\n\r\n### Affected Browsers\r\n\r\nI have confirmed this in these browsers:\r\n\r\nSafari 8.0.5 on OS 10.10.3\r\nFirefox 37.0.2 on OS 10.10.3\r\n\r\nThe following browser is **not** affected and the call to `removeChild()` succeeds when using the full library:\r\n\r\nChrome 42.0.2311.90\r\n\r\nI have not tested any other browsers.\r\n\r\n### Version\r\n\r\nI am using webcomponents.js 0.6.1. The same issue manifests in 0.5.5, so it does not look like a regression. \r\n\r\n\r\n### Better Error Messages\r\n\r\nIt might be a good idea to write more descriptive error messages than \"Assertion failure\". It might **seem** obvious to you guys that if you want to understand the assertion, you just go look at the source code for the library. But that is not helpful for outsiders. And a vague message like \"Assertion failure\" gives us nothing to Google to see how other folks have solved this problem. A more descriptive message of exactly **what** assertion failed would be much better.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/webcomponents/webcomponentsjs/issues/comments/97476935","html_url":"https://github.com/webcomponents/webcomponentsjs/issues/297#issuecomment-97476935","issue_url":"https://api.github.com/repos/webcomponents/webcomponentsjs/issues/297","id":97476935,"user":{"login":"jmesserly","id":1081711,"avatar_url":"https://avatars.githubusercontent.com/u/1081711?v=3","gravatar_id":"","url":"https://api.github.com/users/jmesserly","html_url":"https://github.com/jmesserly","followers_url":"https://api.github.com/users/jmesserly/followers","following_url":"https://api.github.com/users/jmesserly/following{/other_user}","gists_url":"https://api.github.com/users/jmesserly/gists{/gist_id}","starred_url":"https://api.github.com/users/jmesserly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmesserly/subscriptions","organizations_url":"https://api.github.com/users/jmesserly/orgs","repos_url":"https://api.github.com/users/jmesserly/repos","events_url":"https://api.github.com/users/jmesserly/events{/privacy}","received_events_url":"https://api.github.com/users/jmesserly/received_events","type":"User","site_admin":false},"created_at":"2015-04-29T15:50:26Z","updated_at":"2015-04-29T15:50:26Z","body":"oldLink is not a wrapped Shadow DOM Polyfill node. This can happen if you got it directly via the `document` property, which we cannot polyfill:\r\n```js\r\n// won't work! this is bypassing the polyfill\r\nvar oldLink = document.head.lastChild;\r\n// assertion that catches the bug:\r\noldLink.parentNode.removechild(oldLink);\r\n```\r\nInstead use:\r\n```js\r\n// By calling a method, in this case querySelector, the polyfill can kick in (yay!)\r\nvar oldLink = document.querySelector('head').lastChild;\r\n// no more assert\r\noldLink.parentNode.removechild(oldLink);\r\n```\r\n\r\nUnfortunately, there is no possible way to fix `document` or `document.head` in current browsers, as much as I would like to. Sadly that's the nature of polyfills :\\\r\n"}}