Skip to content

Instantly share code, notes, and snippets.

@akoppela
Created April 22, 2011 05:36
Show Gist options
  • Save akoppela/936113 to your computer and use it in GitHub Desktop.
Save akoppela/936113 to your computer and use it in GitHub Desktop.
findDocument: function(target) {
if (target.documentElement) return target;
if (target.document) return target.document;
if (target.lsd) return;
var body = target.ownerDocument.body;
var document = (target != body) && Element.retrieve(body, 'widget');
while (!document && (target = target.parentNode)) {
var widget = Element.retrieve(target, 'widget')
if (widget) document = (widget instanceof LSD.Document) ? widget : widget.document;
}
return document;
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment