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

Move polyfill from a module import to "native" Ember.String.isHTMLSafe #2

Merged
merged 5 commits into from
Mar 3, 2017
Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 2 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,5 @@
/connect.lock
/coverage/*
/libpeerconnection.log
npm-debug.log
npm-debug.log*
testem.log
2 changes: 1 addition & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
"strict": false,
"white": false,
"eqnull": true,
"esnext": true,
"esversion": 6,
"unused": true
}
21 changes: 14 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
language: node_js
node_js:
- "0.12"
- "4"

sudo: false

cache:
directories:
- node_modules
- $HOME/.npm
- $HOME/.cache # includes bowers cache

env:
- EMBER_TRY_SCENARIO=ember-1.10
Expand All @@ -20,24 +21,30 @@ env:
- EMBER_TRY_SCENARIO=ember-2.3
- EMBER_TRY_SCENARIO=ember-2.4
- EMBER_TRY_SCENARIO=ember-2.5
- EMBER_TRY_SCENARIO=ember-2.6
- EMBER_TRY_SCENARIO=ember-2.7
- EMBER_TRY_SCENARIO=ember-lts-2.8
- EMBER_TRY_SCENARIO=ember-release
- EMBER_TRY_SCENARIO=ember-beta
- EMBER_TRY_SCENARIO=ember-canary
- EMBER_TRY_SCENARIO=ember-default

matrix:
fast_finish: true
allow_failures:
- env: EMBER_TRY_SCENARIO=ember-canary

before_install:
- export PATH=/usr/local/phantomjs-2.0.0/bin:$PATH
- "npm config set spin false"
- "npm install -g npm@^2"
- npm config set spin false
- npm install -g bower phantomjs-prebuilt
- bower --version
- phantomjs --version

install:
- npm install -g bower
- npm install
- bower install

script:
- ember try $EMBER_TRY_SCENARIO test
# Usually, it's ok to finish the test scenario without reverting
# to the addon's original dependency state, skipping "cleanup".
- node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO test --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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ember-cli made a mistake here (and we are revertting the update to the LICENSE.md blueprint).

@Panman8201 - Can you change this to 2016-2017 instead of just updating to 2017?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually manually made that change, not ember-cli's fault! :) I'll change it to your suggestion.


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
46 changes: 32 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# ember-string-ishtmlsafe-polyfill
# ember-string-ishtmlsafe-polyfill [![Build Status](https://travis-ci.org/workmanw/ember-string-ishtmlsafe-polyfill.svg?branch=master)](https://travis-ci.org/workmanw/ember-string-ishtmlsafe-polyfill)

This provides a polyfill for the `Ember.String.isHTMLSafe` feature that has landed in ember/master. It is likely to ship with Ember 2.8 or 2.9.
This provides a polyfill for the `Ember.String.isHTMLSafe` feature added in Ember 2.8.

RFC: [emberjs/rfcs#139](https://github.com/emberjs/rfcs/pull/139).

PR: [emberjs/ember.js#13666](https://github.com/emberjs/ember.js/pull/13666).

API: [Ember.String.htmlSafe](http://emberjs.com/api/classes/Ember.String.html#method_isHTMLSafe)


## Installation

Expand All @@ -15,24 +17,40 @@ ember install ember-string-ishtmlsafe-polyfill


## Usage

```javascript
import isHTMLSafe from 'ember-string-ishtmlsafe-polyfill';

export default Ember.Service.extend({
someMethod(str) {
if (isHTMLSafe(str)) {
str = str.toString();
}
// Do something with native string
}
});
import Ember from 'ember';

var plainString = 'plain string';
var safeString = Ember.String.htmlSafe('<div>someValue</div>');

Ember.String.isHTMLSafe(plainString); // false
Ember.String.isHTMLSafe(safeString); // true
```


## Migration

### Applications

After you upgrade your application to Ember 2.8, you should remove `ember-string-ishtmlsafe-polyfill`
from your `package.json`.

### Addons

Addons generally support many different Ember versions, so leaving `ember-string-ishtmlsafe-polyfill`
in place for consumers of your addon is perfectly normal. When the addon no longer supports
Ember versions older than 2.8, we recommend removing `ember-string-ishtmlsafe-polyfill` from
your `package.json` and doing a major version bump.


## Compatibility

This addon is tested against each minor ember version starting with 1.10 through 2.5. Additionally tested against,
`ember-stable`, `ember-beta`, and `ember-canary`. A complete list can be found in the [`ember-try.js](https://github.com/workmanw/ember-string-ishtmlsafe-polyfill/blob/master/config/ember-try.js) config.
This addon is tested against each minor ember version starting with 1.10 through 2.8
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/ember/Ember/

(when `isHTMLSafe()` landed). Additionally tested against, `ember-stable`, `ember-beta`,
and `ember-canary`. A complete list can be found in the
[`ember-try.js`](https://github.com/workmanw/ember-string-ishtmlsafe-polyfill/blob/master/config/ember-try.js)
config.


## Running Tests
Expand Down
Empty file removed addon/.gitkeep
Empty file.
9 changes: 5 additions & 4 deletions addon/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import Ember from 'ember';

function isHTMLSafePolyfill(str) {
return str && typeof str.toHTML === 'function';
}
Ember.deprecate("ember-string-ishtmlsafe-polyfill is now a true polyfill. Use Ember.String.isHTMLSafe directly instead of importing from ember-string-ishtmlsafe-polyfill", false, {
id: "ember-string-ishtmlsafe-polyfill.import",
until: '2.0.0'
});

export default Ember.String.isHTMLSafe || isHTMLSafePolyfill;
export default Ember.String.isHTMLSafe;
7 changes: 1 addition & 6 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
{
"name": "ember-string-ishtmlsafe-polyfill",
"dependencies": {
"ember": "~2.4.3",
"ember-cli-shims": "0.1.1",
"ember-cli-test-loader": "0.2.2",
"ember-qunit-notifications": "0.1.0"
}
"dependencies": {}
}
Loading