Skip to content

Render associated element in error console#7277

Merged
dreamofabear merged 1 commit intomasterfrom
error-element
Feb 1, 2017
Merged

Render associated element in error console#7277
dreamofabear merged 1 commit intomasterfrom
error-element

Conversation

@dreamofabear
Copy link
Copy Markdown

  • Improves error messaging by rendering the associated element natively with mouse-over highlighting, consistent with errors reported by assert()
  • Tested on Chrome 55 and Safari 10

/to @cramforce /cc @jridgewell

element.tagName.toLowerCase() +
(element.id ? ' with id ' + element.id : '') + ':',
error.message);
output.call(console, error.message, element);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll explain my original thinking behind the old state. Lets discuss that, but I tend to agree that your PR makes things better:

I felt people might be confused that the DOM, especially when printed to the console looks different from their raw HTML -> Because we add all kinds of classes and attributes to it, add child elements, etc.

Having said that, this is probably better. Certainly in your case, where the elements aren't always an AmpElement and mutation from original source is expected.

Could you add a screenshot of the Chrome console to the PR description?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Main reason for me is to make this API easier to use -- right now the only way to render the element is to set error.messageArray, which isn't done in error() or createError().

Before:
screen shot 2017-02-01 at 12 12 05 pm

After:
screen shot 2017-02-01 at 12 16 27 pm

For comparison, error generated by assert():
screen shot 2017-02-01 at 12 17 01 pm

@dreamofabear
Copy link
Copy Markdown
Author

Thanks!

@dreamofabear dreamofabear merged commit a7d39a7 into master Feb 1, 2017
@dreamofabear dreamofabear deleted the error-element branch February 1, 2017 23:12
torch2424 pushed a commit to torch2424/amphtml that referenced this pull request Feb 14, 2017
mrjoro pushed a commit to mrjoro/amphtml that referenced this pull request Apr 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants