File tree Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -158,8 +158,16 @@ function init() {
158158 var req = new window . XMLHttpRequest ( )
159159
160160 req . addEventListener ( 'load' , function ( ) {
161- proposals = JSON . parse ( req . responseText )
162-
161+ let evolutionMetadata = JSON . parse ( req . responseText , flattenStatus )
162+
163+ // Temporary conditional to allow script to work with old and new schemas
164+ if ( Array . isArray ( evolutionMetadata ) ) { // current schema
165+ proposals = evolutionMetadata
166+ } else { // new schema
167+ proposals = evolutionMetadata . proposals
168+ languageVersions = evolutionMetadata . implementationVersions
169+ }
170+
163171 // Don't display malformed proposals
164172 proposals = proposals . filter ( function ( proposal ) {
165173 return ! proposal . errors
@@ -201,6 +209,18 @@ function init() {
201209 req . send ( )
202210}
203211
212+ /**
213+ * Reviver function passed to JSON.parse() to convert new status field structure to old structure.
214+ */
215+ function flattenStatus ( key , value ) {
216+ if ( key == "status" && value !== "" && ! value . state ) {
217+ let [ subkey , subvalue ] = Object . entries ( value ) [ 0 ]
218+ subvalue . state = "." + subkey
219+ return subvalue
220+ }
221+ return value
222+ }
223+
204224/**
205225 * Creates an Element. Convenience wrapper for `document.createElement`.
206226 *
You can’t perform that action at this time.
0 commit comments