Skip to content

Commit 95c5538

Browse files
committed
Skip defining getters and setters on IE8 entirely, automate defining fallbacks
1 parent 54283d3 commit 95c5538

File tree

14 files changed

+146
-49
lines changed

14 files changed

+146
-49
lines changed

dist/protobuf.js

Lines changed: 57 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/protobuf.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/protobuf.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/protobuf.min.js.gz

91 Bytes
Binary file not shown.

dist/protobuf.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/enum.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function Enum(name, values, options) {
3535
this._valuesById = null;
3636
}
3737

38-
Object.defineProperties(EnumPrototype, {
38+
util.props(EnumPrototype, {
3939

4040
/**
4141
* Enum values by id.
@@ -44,7 +44,7 @@ Object.defineProperties(EnumPrototype, {
4444
* @readonly
4545
*/
4646
valuesById: {
47-
get: EnumPrototype.getValuesById = function getValuesById() {
47+
get: function getValuesById() {
4848
if (!this._valuesById) {
4949
this._valuesById = {};
5050
Object.keys(this.values).forEach(function(name) {

src/field.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ function Field(name, id, type, rule, extend, options) {
141141
this._packed = null;
142142
}
143143

144-
Object.defineProperties(FieldPrototype, {
144+
util.props(FieldPrototype, {
145145

146146
/**
147147
* Determines whether this field is packed. Only relevant when repeated and working with proto2.

src/inherits.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ function inherits(clazz, type, options) {
124124

125125
}, true);
126126

127-
Object.defineProperties(clazz, classProperties);
127+
util.props(clazz, classProperties);
128128
var prototype = inherits.defineProperties(new Prototype(), type);
129129
clazz.prototype = prototype;
130130
prototype.constructor = clazz;
@@ -167,9 +167,8 @@ inherits.defineProperties = function defineProperties(prototype, type) {
167167

168168
// Define each oneof with a non-enumerable getter and setter for the present field
169169
type.getOneofsArray().forEach(function(oneof) {
170-
oneof.resolve();
171-
prototypeProperties[oneof.name] = {
172-
get: prototype['get' + oneof.ucName] = function() {
170+
util.prop(prototype, oneof.resolve().name, {
171+
get: function getVirtual() {
173172
var keys = oneof.oneof;
174173
for (var i = 0; i < keys.length; ++i) {
175174
var field = oneof.parent.fields[keys[i]];
@@ -178,16 +177,16 @@ inherits.defineProperties = function defineProperties(prototype, type) {
178177
}
179178
return undefined;
180179
},
181-
set: prototype['set' + oneof.ucName] = function(value) {
180+
set: function setVirtual(value) {
182181
var keys = oneof.oneof;
183182
for (var i = 0; i < keys.length; ++i) {
184183
if (keys[i] !== value)
185184
delete this[keys[i]];
186185
}
187186
}
188-
};
187+
});
189188
});
190189

191-
Object.defineProperties(prototype, prototypeProperties);
190+
util.props(prototype, prototypeProperties);
192191
return prototype;
193192
};

src/namespace.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function clearCache(namespace) {
4646
return namespace;
4747
}
4848

49-
Object.defineProperties(NamespacePrototype, {
49+
util.props(NamespacePrototype, {
5050

5151
/**
5252
* Nested objects of this namespace as an array for iteration.
@@ -55,7 +55,7 @@ Object.defineProperties(NamespacePrototype, {
5555
* @readonly
5656
*/
5757
nestedArray: {
58-
get: NamespacePrototype.getNestedArray = function getNestedArray() {
58+
get: function getNestedArray() {
5959
return this._nestedArray || (this._nestedArray = util.toArray(this.nested));
6060
}
6161
}

src/object.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function ReflectionObject(name, options) {
5050
/** @alias ReflectionObject.prototype */
5151
var ReflectionObjectPrototype = ReflectionObject.prototype;
5252

53-
Object.defineProperties(ReflectionObjectPrototype, {
53+
util.props(ReflectionObjectPrototype, {
5454

5555
/**
5656
* Reference to the root namespace.
@@ -59,7 +59,7 @@ Object.defineProperties(ReflectionObjectPrototype, {
5959
* @readonly
6060
*/
6161
root: {
62-
get: ReflectionObjectPrototype.getRoot = function getRoot() {
62+
get: function getRoot() {
6363
var ptr = this;
6464
while (ptr.parent !== null)
6565
ptr = ptr.parent;

0 commit comments

Comments
 (0)