question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Elements missing outerHTML

See original GitHub issue

Because toString() on an element in the browser returns something like “[object HTMLDivElement]”, I have a helper function like this in my tests that run on both server and browser:

function toStr (el) {
  return el.outerHTML || String(el);
}

Could elements in min-document have an outerHTML as well for parity?

Issue Analytics

  • State:open
  • Created 9 years ago
  • Reactions:1
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
shamacommented, May 30, 2015

I would also like support for outerHTML so the exact same code can run client/server.

This seems like a good use for a getter in the constructor to so I’m curious why you want to avoid it:

Object.defineProperty(this, 'outerHTML', {
  get: function() { return this.toString() }
})

Otherwise this lib would have to monitor changes to itself and render upon each to the property; which sounds a lot more horrible IMO.

0reactions
chromakodecommented, Mar 18, 2016

Thanks for the clarification 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Element.outerHTML - Web APIs - MDN Web Docs
The outerHTML attribute of the Element DOM interface gets the serialized HTML fragment describing the element including its descendants.
Read more >
returning element altered by outerHTML - Stack Overflow
What you'll notice is that the reference is to the original element, after outerHTML is used. This is as stated in the documentation:....
Read more >
Property 'outerHTML' missing from 'Element' #14667 - GitHub
MDN claims it exists on Element https://developer.mozilla.org/en-US/docs/Web/API/Element/outerHTML. It is missing from lib.dom.d.ts .
Read more >
outerHTML in the JavaScript DOM - YouTube
The Element. outerHTML property of the Document Object Model allows you to both set and get the outerHTML of an Element.
Read more >
outerHTML jQuery Plugin - CSS-Tricks
innerHTML () is native and returns the contents of a DOM node (e.g. I live inside a div.. outerHTML() is not, which would...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found