lindelwa122 / dom-wizard

JavaScript library that makes DOM manipulation easy and more managable.
MIT License
7 stars 8 forks source link

Read DOM feature #17

Closed sinster2003 closed 12 months ago

sinster2003 commented 1 year ago

Description of Code

  1. The readContent function returns an object containing the read function. The user can access it by calling that method.
  2. The read function does few things:

Any feedbacks or suggestions are gladly accepted and do ask the working of code if there are any clarifications

lindelwa122 commented 1 year ago

Hey, @sinster2003, thanks for your efforts on this feature. I appreciate your approach, but there are a few aspects that could use improvement.

The wording might have been a bit misleading in my initial instructions. The goal is not only to retrieve a specific attribute of an element but to access all of its properties. For instance, you used getAttribute() to obtain a property or attribute of an element. While getAttribute('class') will return the class names of an element, getAttribute('className') will return null. Similarly, getAttribute() returns null for other values like style, innerHTML, etc. Instead of using getAttribute(), you should use this syntax: element[propertyName]. To maintain clarity, we can rename the parameter from attributeName to propertyName.

Regarding the attributeValidation function, we don't need it to be overly complex. The key point is to throw an error if element[propertyName] is undefined.

Additionally, it's a convention to prefix all private methods and variables with an underscore. Please remember to document your method in the DOCS file. Thank you!

sinster2003 commented 1 year ago

@lindelwa122 ya I got your point will improve on these aspects

sinster2003 commented 1 year ago

As an update, @lindelwa122 worked on the improvements, removed all the complexities of the code and property syntax is used... working on the documentation will edit the pull request soon.

sinster2003 commented 12 months ago

@lindelwa122 got some branch conflicts will resolve soon for a PR