{"action":"created","issue":{"url":"https://api.github.com/repos/dart-lang/sdk/issues/25871","repository_url":"https://api.github.com/repos/dart-lang/sdk","labels_url":"https://api.github.com/repos/dart-lang/sdk/issues/25871/labels{/name}","comments_url":"https://api.github.com/repos/dart-lang/sdk/issues/25871/comments","events_url":"https://api.github.com/repos/dart-lang/sdk/issues/25871/events","html_url":"https://github.com/dart-lang/sdk/issues/25871","id":136711600,"number":25871,"title":"JS interop corrupt DOM element if is used as argument in dart 1.14 and above","user":{"login":"mouze","id":6882431,"avatar_url":"https://avatars.githubusercontent.com/u/6882431?v=3","gravatar_id":"","url":"https://api.github.com/users/mouze","html_url":"https://github.com/mouze","followers_url":"https://api.github.com/users/mouze/followers","following_url":"https://api.github.com/users/mouze/following{/other_user}","gists_url":"https://api.github.com/users/mouze/gists{/gist_id}","starred_url":"https://api.github.com/users/mouze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mouze/subscriptions","organizations_url":"https://api.github.com/users/mouze/orgs","repos_url":"https://api.github.com/users/mouze/repos","events_url":"https://api.github.com/users/mouze/events{/privacy}","received_events_url":"https://api.github.com/users/mouze/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dart-lang/sdk/labels/area-library","name":"area-library","color":"c7def8"},{"url":"https://api.github.com/repos/dart-lang/sdk/labels/library-html","name":"library-html","color":"d4c5f9"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-26T14:23:28Z","updated_at":"2016-02-29T13:04:41Z","closed_at":null,"body":"For our application we need to work with DOM elements inside iFrame.\r\nBecause DART does not allow cross-frame access even if window use same origin I must make little hack:\r\n\r\nIn DART:\r\n```\r\n//define JS function:\r\n@JS(\"replaceElementInIframe\")\r\nexternal bool _replaceElementInIframe(frameSelector, elementSelector, newelement);\r\n\r\n//make element:\r\nvar div = new html.DivElement();\r\n// call JS\r\n_replaceElementInIframe(iFrameSelector, innerDivSelector, div);\r\n```\r\n\r\nIn JS function do something like this:\r\n```\r\nwindow.replaceElementInIframe = function (frameSelector, elementSelector, newelement){\r\n        // select iframe\r\n\tvar frame = document.querySelector(frameSelector)\r\n\r\n        // select document\r\n        var doc = (frame.contentWindow ? frame.contentWindow.document : frame.contentDocument);\r\n\r\n        // select element inside iframe\r\n\tvar foundedElement = doc.querySelector(elementSelector);\r\n\r\n        // replace element inside iframe by element given as argument from DART\r\n\tfoundedElement.parentNode.replaceChild(newelement, foundedElement);\r\n\treturn true;\r\n }\r\n\r\n```\r\n\r\nIn DART 1.13 and before\r\nAfter I call _replaceElementInIframe I can take from div his ownerDocument without error and work with it as I want. For example insert other nodes to it, listen events ...\r\n\r\nIn DART 1.14 and above (1.15.0-dev.4.0 (ref 43e12db))\r\nWhen I try to read ownerDocument from div, DART throws exception:\r\ntype 'JsObjectImpl' is not a subtype of type 'Document' of 'function result'.\r\n(Same error is thrown if I try to read div.parentNode)\r\n\r\n\r\nI try to use package:js and dart:js with same result. (with dart:js is little different code)\r\n\r\nThis is very limiting for us, because we cannot upgrade from DART 1.13 where are some other bugs which may be repaired in 1.14"},"comment":{"url":"https://api.github.com/repos/dart-lang/sdk/issues/comments/190201927","html_url":"https://github.com/dart-lang/sdk/issues/25871#issuecomment-190201927","issue_url":"https://api.github.com/repos/dart-lang/sdk/issues/25871","id":190201927,"user":{"login":"anders-sandholm","id":3276024,"avatar_url":"https://avatars.githubusercontent.com/u/3276024?v=3","gravatar_id":"","url":"https://api.github.com/users/anders-sandholm","html_url":"https://github.com/anders-sandholm","followers_url":"https://api.github.com/users/anders-sandholm/followers","following_url":"https://api.github.com/users/anders-sandholm/following{/other_user}","gists_url":"https://api.github.com/users/anders-sandholm/gists{/gist_id}","starred_url":"https://api.github.com/users/anders-sandholm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anders-sandholm/subscriptions","organizations_url":"https://api.github.com/users/anders-sandholm/orgs","repos_url":"https://api.github.com/users/anders-sandholm/repos","events_url":"https://api.github.com/users/anders-sandholm/events{/privacy}","received_events_url":"https://api.github.com/users/anders-sandholm/received_events","type":"User","site_admin":false},"created_at":"2016-02-29T13:04:40Z","updated_at":"2016-02-29T13:04:40Z","body":"Not sure if this is an HTML lib issue at the root - or if this is something that needs fixing in our JS interop story. Please re-label accordingly."}}