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

Including sanitize.js configurations in the Sanitize global object #10

Open
jcano opened this issue May 19, 2016 · 1 comment
Open

Including sanitize.js configurations in the Sanitize global object #10

jcano opened this issue May 19, 2016 · 1 comment

Comments

@jcano
Copy link

jcano commented May 19, 2016

While it is possible to just copy the three files from sanitize.js to app/sanitizers/ (don't know why they are not included by default) it would be very useful to have those configurations in the global Sanitize object.

I know ember-sanitize is meant to be used as a template helper, but as it's already importing sanitize.js and it is possible to use the sanitizer from a Javascript file normally, for example to clean the user input before storing it in the database:

const s = new Sanitize( basic );
let div = document.createElement( "DIV" );
div.innerHTML = model.get( "long_text_field" );

const clean = s.clean_node( div );

div = document.createElement( "DIV" );
div.appendChild( clean );

model.set( "long_text_field", Ember.String.htmlSafe( div.innerHTML ) );

(If there is an easier way to use sanitize.js, please let me know)

By using files for configuration, every component/route/controller/service using the sanitizer would be required to navigate the paths to include the files (e.g. import basic from "../../../sanitizers/basic") with an added cost to maintain.

@jcano
Copy link
Author

jcano commented May 20, 2016

I just realized that my last comment is wrong. From anywhere on an Ember app you can get to the app folder by using the app name, for example appname/sanitizers/basic.

I still believe it would be a good addition and potentially solve issues like #5

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

1 participant