Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,8 @@ insert_final_newline = true
indent_style = space
indent_size = 2

[*.js]
indent_style = space
indent_size = 2

[*.hbs]
insert_final_newline = false
indent_style = space
indent_size = 2

[*.css]
indent_style = space
indent_size = 2

[*.html]
indent_style = space
indent_size = 2

[*.{diff,md}]
trim_trailing_whitespace = false
13 changes: 13 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 2017,
sourceType: 'module'
},
extends: 'eslint:recommended',
env: {
browser: true
},
rules: {
}
};
10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
# See https://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
Expand All @@ -13,5 +13,11 @@
/connect.lock
/coverage/*
/libpeerconnection.log
npm-debug.log
npm-debug.log*
yarn-error.log
testem.log

# ember-try
.node_modules.ember-try/
bower.json.ember-try
package.json.ember-try
32 changes: 0 additions & 32 deletions .jshintrc

This file was deleted.

7 changes: 6 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@
.editorconfig
.ember-cli
.gitignore
.jshintrc
.eslintrc.js
.watchmanconfig
.travis.yml
bower.json
ember-cli-build.js
testem.js

# ember-try
.node_modules.ember-try/
bower.json.ember-try
package.json.ember-try
36 changes: 23 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
---
language: node_js
node_js:
# we recommend testing addons with the same minimum supported node version as Ember CLI
# so that your addon works for all apps
- "4"

sudo: false
dist: trusty

addons:
chrome: stable

cache:
yarn: true
directories:
- node_modules
- $HOME/.npm

env:
- EMBER_TRY_SCENARIO=default
- EMBER_TRY_SCENARIO=ember-1.13
- EMBER_TRY_SCENARIO=ember-release
- EMBER_TRY_SCENARIO=ember-beta
- EMBER_TRY_SCENARIO=ember-canary
global:
# See https://git.io/vdao3 for details.
- JOBS=1
matrix:
# we recommend new addons test the current and previous LTS
# as well as latest stable release (bonus points to beta/canary)
- EMBER_TRY_SCENARIO=ember-lts-2.12
- EMBER_TRY_SCENARIO=ember-lts-2.16
- EMBER_TRY_SCENARIO=ember-release
- EMBER_TRY_SCENARIO=ember-beta
- EMBER_TRY_SCENARIO=ember-canary
- EMBER_TRY_SCENARIO=ember-default

matrix:
fast_finish: true
Expand All @@ -23,14 +37,10 @@ matrix:

before_install:
- npm config set spin false
- npm install -g bower
- npm install phantomjs-prebuilt

install:
- npm install
- bower install
- npm install -g npm@4
- npm --version

script:
# Usually, it's ok to finish the test scenario without reverting
# to the addon's original dependency state, skipping "cleanup".
- ember try $EMBER_TRY_SCENARIO test --skip-cleanup
- node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO --skip-cleanup
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016
Copyright (c) 2017

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
14 changes: 2 additions & 12 deletions addon/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,2 @@
import {
sanitize,
sanitizeElement
} from './utils/sanitize';

import SanitizeMixin from './mixins/sanitize';

export {
sanitize,
sanitizeElement,
SanitizeMixin
};
export { sanitize, sanitizeElement } from './utils/sanitize';
export { default as SanitizeMixin } from './mixins/sanitize';
12 changes: 7 additions & 5 deletions addon/mixins/sanitize.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import Ember from 'ember';
import { sanitize, sanitizeElement } from '../utils/sanitize';
import getOwner from 'ember-getowner-polyfill';

const { getOwner } = Ember;

function loadConfig(container, name) {
if (!name) { return; }
return container.lookup("sanitizer:"+name);
if (name) {
return container.lookup(`sanitizer:${name}`);
}
}

export default Ember.Mixin.create({
sanitizeElement: function(selector, configName) {
sanitizeElement(selector, configName) {
var element = this.$(selector)[0];
return sanitizeElement(element, loadConfig(this.container, configName));
},

sanitizeHTML: function(html, configName) {
sanitizeHTML(html, configName) {
return sanitize(html, loadConfig(getOwner(this), configName));
}
});
12 changes: 6 additions & 6 deletions app/helpers/sanitize-html.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { sanitize } from 'ember-sanitize/utils/sanitize';
import getOwner from 'ember-getowner-polyfill';
import Ember from 'ember';
import { sanitize } from 'ember-sanitize/utils/sanitize';

const { getOwner } = Ember;

export default Ember.Helper.extend({
compute(params) {
let config, configName = params[1];
compute([input, configName]) {
let config;
if (configName) {
//lookup the config
config = getOwner(this).lookup('sanitizer:' + configName);
}

let sanitized = sanitize(params[0], config);
let sanitized = sanitize(input, config);
return new Ember.String.htmlSafe(sanitized);
}
});
11 changes: 2 additions & 9 deletions app/initializers/setup-sanitizers.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import Ember from 'ember';

export default {
name: 'ember-sanitize-setup-sanitizers',

initialize: function(container) {
if (container.registerOptionsForType) {
container.registerOptionsForType('sanitizer', { instantiate: false });
} else {
// Ember < 2
container.optionsForType('sanitizer', { instantiate: false });
}
initialize(container) {
container.registerOptionsForType('sanitizer', { instantiate: false });
}
};
4 changes: 0 additions & 4 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{
"name": "ember-sanitize",
"dependencies": {
"ember": "~2.6.0",
"ember-cli-shims": "0.1.1",
"ember-cli-test-loader": "0.2.2",
"ember-qunit-notifications": "0.1.0",
"sanitize.js": "^1.0.0"
}
}
42 changes: 31 additions & 11 deletions config/ember-try.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
/*jshint node:true*/
/* eslint-env node */
module.exports = {
scenarios: [
{
name: 'default',
bower: {
dependencies: { }
name: 'ember-lts-2.12',
npm: {
devDependencies: {
'ember-source': '~2.12.0'
}
}
},
{
name: 'ember-1.13',
bower: {
dependencies: {
'ember': '~1.13.0'
},
resolutions: {
'ember': '~1.13.0'
name: 'ember-lts-2.16',
npm: {
devDependencies: {
'ember-source': '~2.16.0'
}
}
},
Expand All @@ -27,6 +26,11 @@ module.exports = {
resolutions: {
'ember': 'release'
}
},
npm: {
devDependencies: {
'ember-source': null
}
}
},
{
Expand All @@ -38,6 +42,11 @@ module.exports = {
resolutions: {
'ember': 'beta'
}
},
npm: {
devDependencies: {
'ember-source': null
}
}
},
{
Expand All @@ -49,6 +58,17 @@ module.exports = {
resolutions: {
'ember': 'canary'
}
},
npm: {
devDependencies: {
'ember-source': null
}
}
},
{
name: 'ember-default',
npm: {
devDependencies: {}
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion config/environment.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*jshint node:true*/
/* eslint-env node */
'use strict';

module.exports = function(/* environment, appConfig */) {
Expand Down
9 changes: 5 additions & 4 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/*jshint node:true*/
/* global require, module */
var EmberAddon = require('ember-cli/lib/broccoli/ember-addon');
/* eslint-env node */
'use strict';

const EmberAddon = require('ember-cli/lib/broccoli/ember-addon');

module.exports = function(defaults) {
var app = new EmberAddon(defaults, {
let app = new EmberAddon(defaults, {
// Add options here
});

Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* jshint node: true */
/* eslint-env node */
'use strict';

module.exports = {
Expand Down
Loading