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

Commit

Permalink
feat(node.js): remove attribute method
Browse files Browse the repository at this point in the history
BREAKING CHANGE:

Method attribute does no longer exist. Use property attributes instead.
  • Loading branch information
stfsy committed Mar 27, 2017
1 parent fc93d39 commit ece5e00
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions lib/node.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use strict'

const Attribute = require('./attribute')

const htmlParser = require('htmlparser2')
const domUtils = htmlParser.DomUtils
const fs = require('fs')
Expand Down Expand Up @@ -151,24 +149,7 @@ class Node {
}

/**
* Returns or sets the attribute for the given key and value
* @param {string|Attribute} attr a key for getting an attribute or an attribute for setting the attribute on this node
* @returns {Attribute}
*/
attribute(attr) {
const attributes = this.get().attribs

if (typeof attr === 'string') {
return new Attribute(attr, attributes[attr])
} else if (typeof attr === 'object') {
attributes[attr.key] = attr.value
}

return new Attribute(attr.key, attr.value)
}

/**
* Returns all attributes of this node
* Returns all attributes of this node. The returned object is live, so you can add or remove attributes as you wish
* @returns {Object}
*/
get attributes() {
Expand Down

0 comments on commit ece5e00

Please sign in to comment.