diff --git a/gulpfile.js b/gulpfile.js index 8c3203c7f7..d2fd68f588 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -266,7 +266,7 @@ gulp.task('lint', gulp.series('lint-eslint')); // TODO(timvdlippe): Add back `'generate-externs',` once we can generate externs again gulp.task('update-version', () => { - return gulp.src('lib/utils/boot.js') - .pipe(replace(/(window.Polymer.version = )'\d+\.\d+\.\d+'/, `$1'${require('./package.json').version}'`)) - .pipe(gulp.dest('lib/utils')); + return gulp.src('lib/mixins/element-mixin.js') + .pipe(replace(/(export const version = )'\d+\.\d+\.\d+'/, `$1'${require('./package.json').version}'`)) + .pipe(gulp.dest('lib/mixins')); }); diff --git a/lib/mixins/element-mixin.js b/lib/mixins/element-mixin.js index a8859c96fd..abeb2bde90 100644 --- a/lib/mixins/element-mixin.js +++ b/lib/mixins/element-mixin.js @@ -18,6 +18,12 @@ import { PropertyEffects } from './property-effects.js'; import { PropertiesMixin } from './properties-mixin.js'; import { strictTemplatePolicy, allowTemplateFromDomModule } from '../utils/settings.js'; +/** + * Current Polymer version in Semver notation. + * @type {string} Semver notation of the current version of Polymer. + */ +export const version = '3.0.5'; + /** * Element class mixin that provides the core API for Polymer's meta-programming * features including template stamping, data-binding, attribute deserialization, @@ -302,6 +308,14 @@ export const ElementMixin = dedupingMixin(base => { */ class PolymerElement extends polymerElementBase { + /** + * Current Polymer version in Semver notation. + * @type {string} Semver notation of the current version of Polymer. + */ + static get polymerElementVersion() { + return version; + } + /** * Override of PropertiesMixin _finalizeClass to create observers and * find the template. diff --git a/polymer-element.js b/polymer-element.js index 7188e01b73..0b9dd241d3 100644 --- a/polymer-element.js +++ b/polymer-element.js @@ -9,6 +9,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN */ import { ElementMixin } from './lib/mixins/element-mixin.js'; +export { version } from './lib/mixins/element-mixin.js'; export { html } from './lib/utils/html-tag.js'; /** @@ -27,4 +28,3 @@ export { html } from './lib/utils/html-tag.js'; * attribute deserialization, and property change observation */ export const PolymerElement = ElementMixin(HTMLElement); - diff --git a/test/unit/polymer.element.html b/test/unit/polymer.element.html index cfe9d04055..c17412639a 100644 --- a/test/unit/polymer.element.html +++ b/test/unit/polymer.element.html @@ -417,6 +417,9 @@

Sub template

assert.equal(fixtureEl.getAttribute('prop'), 'propValue'); }); + test('version', function() { + assert.isOk(el.constructor.polymerElementVersion); + }); }); suite('subclass', function() {