Skip to content
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

ele.classes() getter & aliases #2110

Closed
sjneph opened this issue May 12, 2018 · 2 comments
Closed

ele.classes() getter & aliases #2110

sjneph opened this issue May 12, 2018 · 2 comments
Assignees
Milestone

Comments

@sjneph
Copy link
Contributor

sjneph commented May 12, 2018

Allow getting the list of classes on an element as an array, i.e. classArray = ele.classes().

Also allow ele.className() and ele.classNames() as aliases of ele.classes().

OP follows:

--

I find it useful to know which classes might be assigned to a collection. Could you provide a space-separated list method, please? I recommend an implementation similar to the following in classes.js.

  getClasses: function () {
    let ele = this[0];
    return (ele != null)
      ? ele._private.classes.toArray().toString().replace(/,/g, " ")
      : "";
  },
@maxkfranz
Copy link
Member

ele.json().classes

@maxkfranz maxkfranz added this to the future milestone May 14, 2018
@maxkfranz maxkfranz changed the title eles.getClasses() feature request ele.classes() feature request May 14, 2018
@maxkfranz maxkfranz changed the title ele.classes() feature request ele.classNames() feature request May 14, 2018
@maxkfranz
Copy link
Member

maxkfranz commented May 14, 2018

See #2019

It would probably be better to support getting/setting arrays with ele.classNames(), since for v4 it's planned to change the default JSON export to use arrays. That way, classNames() is future-proofed and only old things would need to be changed.

el.classNames(['a', 'b']); // set
el.classNames(); // get
el.classNames([]); // clear

@maxkfranz maxkfranz self-assigned this Jan 17, 2019
@maxkfranz maxkfranz modified the milestones: future, 3.5.0 Feb 7, 2019
@maxkfranz maxkfranz changed the title ele.classNames() feature request ele.classes() getter & aliases Feb 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants