Explicitly set the JS class names for SassNull and SassBoolean (#941)

For whatever reason the default name seems to have changed.
This commit is contained in:
Natalie Weizenbaum 2020-01-24 15:51:50 -08:00 committed by GitHub
parent 5450c1c07b
commit 6234489eaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 0 deletions

View File

@ -94,6 +94,12 @@ class _PropertyDescriptor {
@JS("Object.create")
external Object _create(Object prototype);
/// Sets the name of `object`'s class to `name`.
void setClassName(Object object, String name) {
_defineProperty(getProperty(object, "constructor"), "name",
_PropertyDescriptor(value: name));
}
/// Injects [constructor] into the inheritance chain for [object]'s class.
void injectSuperclass(Object object, Function constructor) {
var prototype = _getPrototypeOf(object);

View File

@ -21,6 +21,7 @@ final Function booleanConstructor = () {
"Use sass.types.Boolean.TRUE or sass.types.Boolean.FALSE instead.";
});
injectSuperclass(sassTrue, constructor);
setClassName(sassTrue, "SassBoolean");
forwardToString(constructor);
setProperty(
getProperty(constructor, "prototype"),

View File

@ -21,6 +21,7 @@ final Function nullConstructor = () {
"instead.";
});
injectSuperclass(sassNull, constructor);
setClassName(sassNull, "SassNull");
forwardToString(constructor);
setProperty(constructor, "NULL", sassNull);
setToString(sassNull, () => "null");