Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Use DOM tree to debug browser against SimpleDOMBuilder #4658

Merged
merged 5 commits into from
Aug 6, 2013

Conversation

jasonsanjose
Copy link
Member

@dangoor @njx

Runtime console warnings when in-editor DOM does not match in-browser DOM.

If there the browser DOM, does not match the in-editor DOM, the diffs are logged to the console. For example, there happens to be an in-browser issue with comments after the <html> tag get reparented to the <body> tag. This results in the following console output:

Browser delta for change: {"from":{"line":12,"ch":33},"to":{"line":12,"ch":34},"text":["BRACKETS"],"removed":["j"],"origin":"undo"} HTMLDocument.js:165
Object {type: "textInsert", tagID: "8", child: 52, content: "↵"} HTMLDocument.js:173
Object {parentID: "8", afterID: "42", type: "textReplace", content: "↵↵    ↵↵"} 

If the structures match, nothing is logged.

This change adds a new remote function getSimpleDOM() that converts the actual DOM tree (the tree vs. outerHTML from my previous implementation) into a JSON structure matching the tree built by SimpleDOMBuilder.

We ignore some diffs including:

  • the brackets live highlight div
  • whitespace deletions inside the html element

Does not handle in-browser DOM modifications yet.

@ghost ghost assigned dangoor Aug 6, 2013
applyEditsPromise = RemoteAgent.call("applyDOMEdits", edits);

// compare in-memory vs. in-browser DOM
// set a conditional breakpoint at the top of this function: "this._debug = true, false"
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on the comment, it seems like this is supposed to be conditional on a debug flag?

Copy link
Member Author

Choose a reason for hiding this comment

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

Removing the comment.

@dangoor
Copy link
Contributor

dangoor commented Aug 6, 2013

Except for those couple of nits, this looks good. I initially couldn't get it to give me output, but that's because the example HTML I was using was too broken (bad things happen when there's no HTML tag).

dangoor added a commit that referenced this pull request Aug 6, 2013
Use DOM tree to debug browser against SimpleDOMBuilder
@dangoor dangoor merged commit bc7ada8 into ResearchLiveHTML Aug 6, 2013
jasonsanjose added a commit that referenced this pull request Aug 6, 2013
dangoor added a commit that referenced this pull request Aug 6, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants