From 05c62f4442a58676689890fdd4d3d66282db9a6e Mon Sep 17 00:00:00 2001 From: Tim van der Lippe Date: Thu, 9 Aug 2018 15:10:35 +0200 Subject: [PATCH 1/3] Export the current Polymer version in polymer-element.js --- gulpfile.js | 6 +++--- polymer-element.js | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 8b584672f2..431ad920c8 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -277,7 +277,7 @@ gulp.task('lint', gulp.series('lint-eslint')); gulp.task('generate-types', gulp.series('generate-typescript')); 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('polymer-element.js') + .pipe(replace(/(export const version = )'\d+\.\d+\.\d+'/, `$1'${require('./package.json').version}'`)) + .pipe(gulp.dest('.')); }); diff --git a/polymer-element.js b/polymer-element.js index 7188e01b73..8cb6e5ccd2 100644 --- a/polymer-element.js +++ b/polymer-element.js @@ -28,3 +28,8 @@ export { html } from './lib/utils/html-tag.js'; */ export const PolymerElement = ElementMixin(HTMLElement); +/** + * Current Polymer version in Semver notation. + * @type {String} Semver notation of the current version of Polymer. + */ +export const version = '3.0.5'; From 2957e9d4b8f2814feb0830e29567eb7c32b5fe34 Mon Sep 17 00:00:00 2001 From: Tim van der Lippe Date: Tue, 14 Aug 2018 12:44:33 +0200 Subject: [PATCH 2/3] Move version to ElementMixin prototype --- lib/mixins/element-mixin.js | 14 ++++++++++++++ polymer-element.js | 7 +------ test/unit/polymer.element.html | 3 +++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/mixins/element-mixin.js b/lib/mixins/element-mixin.js index 861d1b120f..77a140a8fd 100644 --- a/lib/mixins/element-mixin.js +++ b/lib/mixins/element-mixin.js @@ -17,6 +17,12 @@ import { DomModule } from '../elements/dom-module.js'; import { PropertyEffects } from './property-effects.js'; import { PropertiesMixin } from './properties-mixin.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, @@ -278,6 +284,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 8cb6e5ccd2..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,9 +28,3 @@ export { html } from './lib/utils/html-tag.js'; * attribute deserialization, and property change observation */ export const PolymerElement = ElementMixin(HTMLElement); - -/** - * Current Polymer version in Semver notation. - * @type {String} Semver notation of the current version of Polymer. - */ -export const version = '3.0.5'; diff --git a/test/unit/polymer.element.html b/test/unit/polymer.element.html index b81d21e090..c20cfa8e7c 100644 --- a/test/unit/polymer.element.html +++ b/test/unit/polymer.element.html @@ -397,6 +397,9 @@

Sub template

assert.equal(fixtureEl.getAttribute('prop'), 'propValue'); }); + test('version', function() { + assert.isOk(el.constructor.polymerElementVersion); + }); }); suite('subclass', function() { From f845842fc9f4dd80dcb92c4b2ca3ff401491d164 Mon Sep 17 00:00:00 2001 From: Tim van der Lippe Date: Tue, 21 Aug 2018 22:10:57 +0200 Subject: [PATCH 3/3] Update paths in gulpfile --- gulpfile.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 431ad920c8..932d3b1e92 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -277,7 +277,7 @@ gulp.task('lint', gulp.series('lint-eslint')); gulp.task('generate-types', gulp.series('generate-typescript')); gulp.task('update-version', () => { - return gulp.src('polymer-element.js') + return gulp.src('lib/mixins/element-mixin.js') .pipe(replace(/(export const version = )'\d+\.\d+\.\d+'/, `$1'${require('./package.json').version}'`)) - .pipe(gulp.dest('.')); + .pipe(gulp.dest('lib/mixins')); });