Created
February 4, 2020 14:18
-
-
Save ochafik/b2d77a8dfa20d4dafcd32651f830eb68 to your computer and use it in GitHub Desktop.
dart:js IntersectionObserver unwrapping bug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:js'; | |
import 'dart:html'; | |
main() { | |
printJsObject(document.body); | |
var o = IntersectionObserver((entries, observer) { | |
printJsObject(observer); | |
printJsObject(JsObject.fromBrowserObject(observer)); | |
for (final entry in entries) { | |
printJsObject(entry); | |
printJsObject(JsObject.fromBrowserObject(entry)); | |
//final visible = _isVisible.apply([entry]); | |
//final visible = _isVisible.apply([JsObject.fromBrowserObject(entry)]); | |
final visible = JsObject.fromBrowserObject(entry)['isVisible']; | |
print('_isVisible($entry) = $visible'); | |
} | |
}, {'trackVisibility': 'true', 'delay': '500'}); | |
o.observe(document.body); | |
} | |
printJsObject(o) => (JsObject(context['Function'], [''' | |
const o = arguments[0]; | |
console.log(o); | |
console.log(Object.getPrototypeOf(o)); | |
console.log(Object.keys(Object.getPrototypeOf(o))); | |
console.log(''); | |
''']) as JsFunction).apply([o]); | |
final JsFunction _isVisible = JsObject(context['Function'], [''' | |
const entry = arguments[0]; | |
console.log(entry); | |
console.log(Object.getPrototypeOf(entry)); | |
console.log(Object.keys(Object.getPrototypeOf(entry))); | |
return entry.isVisible; | |
''']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment