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

Feat: more trigger options in replace.html #53

Closed
JPeer264 opened this issue Jul 9, 2018 · 0 comments
Closed

Feat: more trigger options in replace.html #53

JPeer264 opened this issue Jul 9, 2018 · 0 comments
Assignees

Comments

@JPeer264
Copy link
Owner

JPeer264 commented Jul 9, 2018

(ref: #52)

By now just id and class attributes will be triggered. data-* or similar attributes will not get triggered.

Suggested options:

  • triggerClassAttributes - for triggering JUST class attributes
  • triggerIdAttributes - for triggering JUST id attributes

Types: <Array|RegExp>

Definition:
If, e.g. triggerClassAttributes has the value [/data-*/, 'my-custom-attribute'], then all data attributes and the my-custom-attribute will get triggered and the content inside will get replaced by just the set class selectors.

Example:

const rcs = require('rcs-core');

// first set the id to replace
rcs.selectorLibrary.set('.my-class');

const replacedHtml = rcs.replace.html(`
  <div>
  	<element
      class="my-class"
      data-anything="my-class"
      my-custom-attribute="my-class"
      any-attribute="my-class"
    />
  </div>
`);

// outputs following:
//  <div>
//   <element
//     class="a"
//     data-anything="a"
//     my-custom-attribute="a"
//     any-attribute="my-class" <-- stays the same
//   />
// </div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant