Open lindelwa122 opened 9 months ago
Hi @lindelwa122 , I stumbled upon your repository while searching for some Hacktoberfest projects. I found it genuinely interesting, and I'm currently working on implementing the read functionality for DOM elements and their attributes. I would love to contribute.
Hey @lindelwa122 , as an update I have worked a little on the read DOM feature I have almost completed it ... yet to rigorously test it and document it ... I will proceed with a pull request soon
Thank you, @sinster2003, for your contribution. I've assigned the feature to you.
Hey @lindelwa122, have made a pull request do review it
@lindelwa122 , I created the read function in a new branch and directly made the changes in index.js starter file where you had written the previous code.. do you want me to change the location to template src folder or anywhere else do mention if needed I will make the changes.
@lindelwa122 , I created the read function in a new branch and directly made the changes in index.js starter file where you had written the previous code.. do you want me to change the location to template src folder or anywhere else do mention if needed I will make the changes.
It's okay, it should be in index.js.
domManager.read
domManager
The domManager module is responsible for creating, updating, reading, and deleting DOM elements.
read()
The
read()
function is responsible for retrieving data from a specific element.Parameters/Inputs:
selector
: stringattributeName
: string (optional)all
: boolean (optional)The function should accept three parameters:
selector
,attributeName
(optional), andall
(optional).The function will utilize
querySelector(selector)
to retrieve the element. If this returns undefined, the function should throw an error. Subsequently, it should return the value of the requested attribute. If theattributeName
is not a qualified name, an error should be thrown. IfattributeName
is not specified, the function should return the element as is. By default,all
is set to false, but if the user setsall
to true, the function should usequerySelectorAll(selector)
instead. Ifall
is true andattributeName
is specified, the function should return an array containing the values of thatattributeName
. For example, if the user invokesdomManager.read(".content", "dataset", true)
, the function should return an array of datasets for elements with a class name of.content
. However, ifattributeName
is not specified andall
is set to true, the function should return a NodeList or an array containing all elements with the specified selector.