regexp.prototype.flags
Advanced tools
Comparing version 1.4.1 to 1.4.2
@@ -8,2 +8,9 @@ # Changelog | ||
## [v1.4.2](https://github.com/es-shims/RegExp.prototype.flags/compare/v1.4.1...v1.4.2) - 2022-04-12 | ||
### Commits | ||
- [Fix] ensure `hasIndices` is patched properly, and getter order is correct [`a1af45a`](https://github.com/es-shims/RegExp.prototype.flags/commit/a1af45a8a6f7305b097b83f96ee9fc45abb3e733) | ||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `auto-changelog`, `tape` [`24f5a0c`](https://github.com/es-shims/RegExp.prototype.flags/commit/24f5a0c84f2e7d263ae0e2008def870afd6d5a4f) | ||
## [v1.4.1](https://github.com/es-shims/RegExp.prototype.flags/compare/v1.4.0...v1.4.1) - 2022-01-13 | ||
@@ -10,0 +17,0 @@ |
{ | ||
"name": "regexp.prototype.flags", | ||
"version": "1.4.1", | ||
"version": "1.4.2", | ||
"author": "Jordan Harband <ljharb@gmail.com>", | ||
@@ -47,9 +47,9 @@ "funding": { | ||
"@es-shims/api": "^2.2.3", | ||
"@ljharb/eslint-config": "^20.2.0", | ||
"@ljharb/eslint-config": "^21.0.0", | ||
"aud": "^2.0.0", | ||
"auto-changelog": "^2.3.0", | ||
"auto-changelog": "^2.4.0", | ||
"available-regexp-flags": "^1.0.0", | ||
"covert": "^1.1.1", | ||
"eclint": "^2.8.1", | ||
"eslint": "^8.6.0", | ||
"eslint": "=8.8.0", | ||
"foreach": "^2.0.5", | ||
@@ -62,3 +62,3 @@ "functions-have-names": "^1.2.2", | ||
"safe-publish-latest": "^2.0.0", | ||
"tape": "^5.4.0" | ||
"tape": "^5.5.3" | ||
}, | ||
@@ -65,0 +65,0 @@ "testling": { |
@@ -11,4 +11,24 @@ 'use strict'; | ||
var descriptor = $gOPD(RegExp.prototype, 'flags'); | ||
if (descriptor && typeof descriptor.get === 'function' && typeof (/a/).dotAll === 'boolean') { | ||
return descriptor.get; | ||
if ( | ||
descriptor | ||
&& typeof descriptor.get === 'function' | ||
&& typeof RegExp.prototype.dotAll === 'boolean' | ||
&& typeof RegExp.prototype.hasIndices === 'boolean' | ||
) { | ||
/* eslint getter-return: 0 */ | ||
var calls = ''; | ||
var o = {}; | ||
Object.defineProperty(o, 'hasIndices', { | ||
get: function () { | ||
calls += 'd'; | ||
} | ||
}); | ||
Object.defineProperty(o, 'sticky', { | ||
get: function () { | ||
calls += 'y'; | ||
} | ||
}); | ||
if (calls === 'dy') { | ||
return descriptor.get; | ||
} | ||
} | ||
@@ -15,0 +35,0 @@ } |
@@ -5,2 +5,3 @@ 'use strict'; | ||
var inspect = require('object-inspect'); | ||
var supportsDescriptors = require('define-properties').supportsDescriptors; | ||
@@ -94,2 +95,49 @@ var forEach = require('foreach'); | ||
}); | ||
t.test('getters', { skip: !supportsDescriptors }, function (st) { | ||
/* eslint getter-return: 0 */ | ||
var calls = ''; | ||
var re = {}; | ||
Object.defineProperty(re, 'hasIndices', { | ||
get: function () { | ||
calls += 'd'; | ||
} | ||
}); | ||
Object.defineProperty(re, 'global', { | ||
get: function () { | ||
calls += 'g'; | ||
} | ||
}); | ||
Object.defineProperty(re, 'ignoreCase', { | ||
get: function () { | ||
calls += 'i'; | ||
} | ||
}); | ||
Object.defineProperty(re, 'multiline', { | ||
get: function () { | ||
calls += 'm'; | ||
} | ||
}); | ||
Object.defineProperty(re, 'dotAll', { | ||
get: function () { | ||
calls += 's'; | ||
} | ||
}); | ||
Object.defineProperty(re, 'unicode', { | ||
get: function () { | ||
calls += 'u'; | ||
} | ||
}); | ||
Object.defineProperty(re, 'sticky', { | ||
get: function () { | ||
calls += 'y'; | ||
} | ||
}); | ||
flags(re); | ||
st.equal(calls, 'dgimsuy', 'getters are called in expected order'); | ||
st.end(); | ||
}); | ||
}; |
35968
289