Skip to content

Commit

Permalink
Fix closure compiler renaming safety. (#465)
Browse files Browse the repository at this point in the history
* Fix renaming-safety for compiling with closure compiler.

JSCompiler_renameProperty can't be exported from a module, it's a global. If it's exported then jscompiler doesn't treat it as special, it's just a normal function.

* Updated CHANGELOG

* Update CHANGELOG.md
  • Loading branch information
rictic authored and dfreedm committed Jan 19, 2019
1 parent ae52ecc commit 4ffa707
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
<!-- ### Changed -->
<!-- ### Removed -->
<!-- ### Fixed -->
## Unreleased

### Fixed
* Fixed a bug where we broke compatibility with closure compiler's property renaming optimizations. JSCompiler_renameProperty can't be a module export ([#465](https://github.com/Polymer/lit-element/pull/465)).

## [2.0.0-rc.3] - 2019-01-18
### Fixed
Expand Down
12 changes: 11 additions & 1 deletion src/lib/updating-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,17 @@
* alias this function, so we have to use a small shim that has the same
* behavior when not compiling.
*/
export const JSCompiler_renameProperty = (prop: PropertyKey, _obj: any) => prop;
window.JSCompiler_renameProperty =
<P extends PropertyKey>(prop: P, _obj: unknown): P => prop;

declare global {
var JSCompiler_renameProperty: <P extends PropertyKey>(
prop: P, _obj: unknown) => P;

interface Window {
JSCompiler_renameProperty: typeof JSCompiler_renameProperty;
}
}

/**
* Converts property values to and from attribute values.
Expand Down
2 changes: 1 addition & 1 deletion src/lit-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import {TemplateResult} from 'lit-html';
import {render} from 'lit-html/lib/shady-render';

import {PropertyValues, UpdatingElement, JSCompiler_renameProperty} from './lib/updating-element.js';
import {PropertyValues, UpdatingElement} from './lib/updating-element.js';

export * from './lib/updating-element.js';
export * from './lib/decorators.js';
Expand Down

0 comments on commit 4ffa707

Please sign in to comment.