-
Notifications
You must be signed in to change notification settings - Fork 43
Fixed typo in master #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sghiassy
wants to merge
2
commits into
azaslavsky:master
Choose a base branch
from
sghiassy:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| domJSON | ||
| ======= | ||
| [](https://github.com/azaslavsky/domJSON#license) [](http://badge.fury.io/bo/domjson) [](http://badge.fury.io/js/domjson) [](https://coveralls.io/r/azaslavsky/domJSON?branch=master) [](https://david-dm.org/azaslavsky/domJSON#info=devDependencies&view=table) [](https://travis-ci.org/azaslavsky/domJSON) | ||
| [](https://github.com/azaslavsky/domJSON#license) [](http://badge.fury.io/bo/domjson) [](http://badge.fury.io/js/domjson) [](https://coveralls.io/r/azaslavsky/domJSON?branch=master) [](https://david-dm.org/azaslavsky/domJSON#info=devDependencies&view=table) [](https://travis-ci.org/azaslavsky/domJSON) | ||
|
|
||
| Convert DOM trees into compact JSON objects, and vice versa, as fast as possible. | ||
|
|
||
|
|
@@ -64,8 +64,8 @@ Coming soon... | |
| Using domJSON is super simple: use the [`.toJSON()`](#domJSON.toJSON) method to create a JSON representation of the DOM tree: | ||
|
|
||
| ```javascript | ||
| var someDOMElement = document.getElementById('sampleId'); | ||
| var jsonOutput = domJSON.toJSON(myDiv); | ||
| let someDOMElement = document.getElementById('sampleId'); | ||
| let jsonOutput = domJSON.toJSON(someDOMElement); | ||
| ``` | ||
|
|
||
| And then rebuild the DOM Node from that JSON using [`.toDOM()`](#domJSON.toDOM): | ||
|
|
@@ -201,22 +201,22 @@ domJSON is a global variable to store two methods: `.toJSON()` to convert a DOM | |
| #### domJSON.toJSON(node, [opts]) ⇒ <code>Object</code> \| <code>string</code> | ||
| Take a DOM node and convert it to simple object literal (or JSON string) with no circular references and no functions or events | ||
|
|
||
| | Param | Type | Description | | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What exactly did you change here? It just seems like you prettified the text and that's it, or am I missing something? |
||
| | ----- | ---- | ----------- | | ||
| | node | <code>Node</code> | The actual DOM Node which will be the starting point for parsing the DOM Tree | | ||
| | \[opts\] | <code>Object</code> | A list of all method options | | ||
| | \[opts.absolutePaths=`'action', 'data', 'href', 'src'`\] | <code>boolean</code> \| <code>[FilterList](#FilterList)</code> | Only relevant if `opts.attributes` is not `false`; use `true` to convert all relative paths found in attribute values to absolute paths, or specify a `FilterList` of keys to boolean search | | ||
| | \[opts.attributes=`true`\] | <code>boolean</code> \| <code>[FilterList](#FilterList)</code> | Use `true` to copy all attribute key-value pairs, or specify a `FilterList` of keys to boolean search | | ||
| | \[opts.computedStyle=`false`\] | <code>boolean</code> \| <code>[FilterList](#FilterList)</code> | Use `true` to parse the results of "window.getComputedStyle()" on every node (specify a `FilterList` of CSS properties to be included via boolean search); this operation is VERY costly performance-wise! | | ||
| | \[opts.cull=`false`\] | <code>boolean</code> | Use `true` to ignore empty element properties | | ||
| | \[opts.deep=`true`\] | <code>boolean</code> \| <code>number</code> | Use `true` to iterate and copy all childNodes, or an INTEGER indicating how many levels down the DOM tree to iterate | | ||
| | \[opts.domProperties=true\] | <code>boolean</code> \| <code>[FilterList](#FilterList)</code> | 'false' means only 'tagName', 'nodeType', and 'nodeValue' properties will be copied, while a `FilterList` can specify DOM properties to include or exclude in the output (except for ones which serialize the DOM Node, which are handled separately by `opts.serialProperties`) | | ||
| | \[opts.htmlOnly=`false`\] | <code>boolean</code> | Use `true` to only iterate through childNodes where nodeType = 1 (aka, instances of HTMLElement); irrelevant if `opts.deep` is `true` | | ||
| | \[opts.metadata=`false`\] | <code>boolean</code> | Output a special object of the domJSON class, which includes metadata about this operation | | ||
| | \[opts.serialProperties=`true`\] | <code>boolean</code> \| <code>[FilterList](#FilterList)</code> | Use `true` to ignore the properties that store a serialized version of this DOM Node (ex: outerHTML, innerText, etc), or specify a `FilterList` of serial properties (no boolean search!) | | ||
| | \[opts.stringify=`false`\] | <code>boolean</code> | Output a JSON string, or just a JSON-ready javascript object? | | ||
|
|
||
| **Returns**: <code>Object</code> \| <code>string</code> - A JSON-friendly object, or JSON string, of the DOM node -> JSON conversion output | ||
| | Param | Type | Description | | ||
| | -------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| | node | <code>Node</code> | The actual DOM Node which will be the starting point for parsing the DOM Tree | | ||
| | \[opts\] | <code>Object</code> | A list of all method options | | ||
| | \[opts.absolutePaths=`'action', 'data', 'href', 'src'`\] | <code>boolean</code> \| <code>[FilterList](#FilterList)</code> | Only relevant if `opts.attributes` is not `false`; use `true` to convert all relative paths found in attribute values to absolute paths, or specify a `FilterList` of keys to boolean search | | ||
| | \[opts.attributes=`true`\] | <code>boolean</code> \| <code>[FilterList](#FilterList)</code> | Use `true` to copy all attribute key-value pairs, or specify a `FilterList` of keys to boolean search | | ||
| | \[opts.computedStyle=`false`\] | <code>boolean</code> \| <code>[FilterList](#FilterList)</code> | Use `true` to parse the results of "window.getComputedStyle()" on every node (specify a `FilterList` of CSS properties to be included via boolean search); this operation is VERY costly performance-wise! | | ||
| | \[opts.cull=`false`\] | <code>boolean</code> | Use `true` to ignore empty element properties | | ||
| | \[opts.deep=`true`\] | <code>boolean</code> \| <code>number</code> | Use `true` to iterate and copy all childNodes, or an INTEGER indicating how many levels down the DOM tree to iterate | | ||
| | \[opts.domProperties=true\] | <code>boolean</code> \| <code>[FilterList](#FilterList)</code> | 'false' means only 'tagName', 'nodeType', and 'nodeValue' properties will be copied, while a `FilterList` can specify DOM properties to include or exclude in the output (except for ones which serialize the DOM Node, which are handled separately by `opts.serialProperties`) | | ||
| | \[opts.htmlOnly=`false`\] | <code>boolean</code> | Use `true` to only iterate through childNodes where nodeType = 1 (aka, instances of HTMLElement); irrelevant if `opts.deep` is `true` | | ||
| | \[opts.metadata=`false`\] | <code>boolean</code> | Output a special object of the domJSON class, which includes metadata about this operation | | ||
| | \[opts.serialProperties=`true`\] | <code>boolean</code> \| <code>[FilterList](#FilterList)</code> | Use `true` to ignore the properties that store a serialized version of this DOM Node (ex: outerHTML, innerText, etc), or specify a `FilterList` of serial properties (no boolean search!) | | ||
| | \[opts.stringify=`false`\] | <code>boolean</code> | Output a JSON string, or just a JSON-ready javascript object? | | ||
|
|
||
| **Returns**: <code>Object</code> \| <code>string</code> - A JSON-friendly object, or JSON string, of the DOM node -> JSON conversion output | ||
| **Todo** | ||
|
|
||
| - {boolean|FilterList} [opts.parse=`false`] a `FilterList` of properties that are DOM nodes, but will still be copied **PLANNED** | ||
|
|
@@ -227,13 +227,13 @@ Take a DOM node and convert it to simple object literal (or JSON string) with no | |
| #### domJSON.toDOM(obj, [opts]) ⇒ <code>DocumentFragment</code> | ||
| Take the JSON-friendly object created by the `.toJSON()` method and rebuild it back into a DOM Node | ||
|
|
||
| | Param | Type | Description | | ||
| | ----- | ---- | ----------- | | ||
| | obj | <code>Object</code> | A JSON friendly object, or even JSON string, of some DOM Node | | ||
| | \[opts\] | <code>Object</code> | A list of all method options | | ||
| | Param | Type | Description | | ||
| | ----------------------- | -------------------- | -------------------------------------------------------------------------------------------------------------------------- | | ||
| | obj | <code>Object</code> | A JSON friendly object, or even JSON string, of some DOM Node | | ||
| | \[opts\] | <code>Object</code> | A list of all method options | | ||
| | \[opts.noMeta=`false`\] | <code>boolean</code> | `true` means that this object is not wrapped in metadata, which it makes it somewhat more difficult to rebuild properly... | | ||
|
|
||
| **Returns**: <code>DocumentFragment</code> - A `DocumentFragment` (nodeType 11) containing the result of unpacking the input `obj` | ||
| **Returns**: <code>DocumentFragment</code> - A `DocumentFragment` (nodeType 11) containing the result of unpacking the input `obj` | ||
|
|
||
|
|
||
| ## Performance | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main change of the PR is just to change
myDivtosomeDOMElement.Also, changed
vartoletto encourage "immutability by default". Perhaps too preachy??There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would prefer to keep it
varsince the rest of the code is written in ES5 (this is an ooooold library ;)). But nice catch on themyDivtypo!