Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronlademann-wf committed Oct 24, 2016
2 parents aa85533 + 58682a4 commit 54b02b9
Show file tree
Hide file tree
Showing 18 changed files with 411 additions and 58 deletions.
24 changes: 24 additions & 0 deletions .analysis_options
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
analyzer:
exclude:
- integrate/**
linter:
rules:
- annotate_overrides
- avoid_empty_else
- avoid_init_to_null
- avoid_return_types_on_setters
- camel_case_types
- empty_constructor_bodies
- hash_and_equals
- library_names
- library_prefixes
- package_api_docs
- package_names
- package_prefixed_library_names
- prefer_is_not_empty
- slash_for_doc_comments
- sort_constructors_first
- sort_unnamed_constructors_first
- type_init_formals
- unnecessary_brace_in_string_interp
- unnecessary_getters_setters
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
language: dart
dart:
- "1.17.1"
with_content_shell: true
before_install:
- export DISPLAY=:99.0
- ./tool/setup_dartium.sh
- export PATH=$PATH":$PWD"
- sh -e /etc/init.d/xvfb start
script:
- pub run dart_dev analyze
- pub run dart_dev test
- ./tool/generate_coverage.sh
- bash <(curl -s https://codecov.io/bash) -f coverage/coverage.lcov
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

```yaml
dependencies:
over_react: "^1.0.0"
over_react: "^1.0.1"
```
2. Add the `over_react` [transformer] to your `pubspec.yaml`.
Expand Down
3 changes: 3 additions & 0 deletions lib/src/component/aria_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ library over_react.aria_mixin;

import 'dart:collection';

// Must import these consts because they are used in the transformed code.
// ignore: unused_import
import 'package:over_react/over_react.dart' show PropDescriptor, ConsumedProps;
import 'package:over_react/src/component_declaration/annotations.dart';

/// Typed getters/setters for accessibility props.
Expand Down
3 changes: 3 additions & 0 deletions lib/src/component/prop_mixins.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
/// Various prop related mixins to be used with [UiComponent] descendants.
library over_react.prop_mixins;

// Must import these consts because they are used in the transformed code.
// ignore: unused_import
import 'package:over_react/over_react.dart' show PropDescriptor, ConsumedProps;
import 'package:over_react/src/component/callback_typedefs.dart';
import 'package:over_react/src/component_declaration/annotations.dart';

Expand Down
6 changes: 1 addition & 5 deletions lib/src/component/resize_sensor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ class ResizeSensorComponent extends UiComponent<ResizeSensorProps> {

Element _expandSensorChildRef;
Element _expandSensorRef;
Element _collapseSensorChildRef;
Element _collapseSensorRef;

@override
Expand Down Expand Up @@ -115,10 +114,7 @@ class ResizeSensorComponent extends UiComponent<ResizeSensorProps> {
..key = 'expandSensor'
)(expandSensorChild);

var collapseSensorChild = (Dom.div()
..ref = (ref) { _collapseSensorChildRef = ref; }
..style = _collapseSensorChildStyle
)();
var collapseSensorChild = (Dom.div()..style = _collapseSensorChildStyle)();

var collapseSensor = (Dom.div()
..className = 'resize-sensor-collapse'
Expand Down
3 changes: 3 additions & 0 deletions lib/src/util/class_names.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ library over_react.class_names;

import 'dart:collection';

// Must import these consts because they are used in the transformed code.
// ignore: unused_import
import 'package:over_react/over_react.dart' show PropDescriptor, ConsumedProps;
import 'package:over_react/src/component_declaration/annotations.dart';

/// Typed getters/setters for props related to CSS class manipulation, and used by all UIP components.
Expand Down
43 changes: 0 additions & 43 deletions lib/src/util/prop_errors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,49 +14,6 @@

library over_react.prop_errors;

/// Error thrown when a prop, that must be set, is not set.
///
/// Deprecated: Use [PropError].required instead.
@Deprecated('2.0.0')
class RequiredPropError extends Error {
final String message;

RequiredPropError(this.message);

@override
String toString() => 'RequiredPropError: $message';
}

/// Error thrown when a prop has an invalid value.
///
/// Deprecated: Use [PropError].value instead.
@Deprecated('2.0.0')
class InvalidPropValueError extends Error {
dynamic value;
String name;
String message;

InvalidPropValueError(this.value, this.name, this.message);

@override
String toString() => "InvalidPropValueError: Prop $name set to ${Error.safeToString(value)}: ${this.message}";
}

/// Error thrown when a two props have incompatible values.
///
/// Deprecated: Use [PropError].combination instead.
@Deprecated('2.0.0')
class InvalidPropCombinationError extends Error {
String prop1;
String prop2;
String message;

InvalidPropCombinationError(this.prop1, this.prop2, this.message);

@override
String toString() => "InvalidPropCombinationError: Prop $prop1 and prop $prop2 are set to incompatible values: ${this.message}";
}

/// Error thrown dues to a prop being set incorrectly.
class PropError extends Error {
static const String defaultPrefix = 'PropError: ';
Expand Down
6 changes: 0 additions & 6 deletions lib/src/util/react_wrappers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,6 @@ ReactElement cloneElement(ReactElement element, [Map props, Iterable children])
}
}

/// Returns whether the React [instance] is mounted.
///
/// Deprecated: Simply call `isMounted` on the [ReactComponent] instead.
@Deprecated('2.0.0')
bool isMounted(ReactComponent instance) => instance.isMounted();

/// Returns the native Dart component associated with a React JS component instance, or null if the component is not Dart-based.
react.Component getDartComponent(/* [1] */ instance) {
if (instance is Element) {
Expand Down
3 changes: 1 addition & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: over_react
publish_to: https://pub.workiva.org
version: 1.0.0
version: 1.0.1
description: A library for building statically-typed React UI components using Dart.
homepage: https://github.com/Workiva/over_react/
authors:
Expand Down
48 changes: 48 additions & 0 deletions test/over_react/util/constants_base_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright 2016 Workiva Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

library constants_base_test;

import 'package:over_react/over_react.dart';
import 'package:test/test.dart';

/// Main entry point for DomUtil testing
main() {
group('DebugFriendlyConstant has the correct', () {
test('toString implementation', () {
var debugConst = const DebugConstantTest('Name');

expect(debugConst.debugDescription, 'Debug Description');
expect(debugConst.toString(), '${debugConst.runtimeType}.Name (Debug Description)');
});

test('debugDescription implementation', () {
var classNameConst = const ClassNameConstantTest('Name', 'ClassName');

expect(classNameConst.debugDescription, 'className: ClassName');
expect(classNameConst.toString(), '${classNameConst.runtimeType}.Name (className: ClassName)');
});
});
}

class DebugConstantTest extends DebugFriendlyConstant {
const DebugConstantTest(String name) : super(name);

@override
String get debugDescription => 'Debug Description';
}

class ClassNameConstantTest extends ClassNameConstant {
const ClassNameConstantTest(String name, String className) : super(name, className);
}
89 changes: 89 additions & 0 deletions test/over_react/util/dom_util_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

library dom_util_test;

import 'dart:html';

import 'package:over_react/over_react.dart';
import 'package:test/test.dart';

Expand Down Expand Up @@ -63,6 +65,93 @@ main() {
});
});
});

group('closest', () {
group('returns the closest node that matches the given selector', () {
test('when the child matches the target selector in addition to its parent', () {
var parent = new DivElement()..className = 'target-class';
var child = new DivElement()..className = 'target-class';
parent.append(child);

expect(closest(child, '.target-class'), child);
});

test('when the parent matches the target selector in addition to its grandparent', () {
var grandparent = new DivElement()..className = 'target-class';
var parent = new DivElement()..className = 'target-class';
var child = new DivElement();
grandparent.append(parent);
parent.append(child);

expect(closest(child, '.target-class'), parent);
});

test('when only the granparent matches the target selector', () {
var grandparent = new DivElement()..className = 'target-class';
var parent = new DivElement();
var child = new DivElement();
grandparent.append(parent);
parent.append(child);

expect(closest(child, '.target-class'), grandparent);
});

test('when an `upperBound` is set that includes the matching ancestor', () {
var grandparent = new DivElement()..className = 'target-class';
var parent = new DivElement();
var child = new DivElement();
grandparent.append(parent);
parent.append(child);

expect(closest(child, '.target-class', upperBound: grandparent), grandparent);
});

test('when an `upperBound` is set the same as `lowerBound`, which matches', () {
var element = new DivElement()..className = 'target-class';
expect(closest(element, '.target-class', upperBound: element), element);
});
});

group('returns null', () {
test('when there are no matching elements', () {
var grandparent = new DivElement();
var parent = new DivElement();
var child = new DivElement();
grandparent.append(parent);
parent.append(child);

expect(closest(child, '.target-class'), isNull);
});

test('when an `upperBound` is set to exclude any matching elements', () {
var grandparent = new DivElement()..className = 'target-class';
var parent = new DivElement();
var child = new DivElement();
grandparent.append(parent);
parent.append(child);

expect(closest(child, '.target-class', upperBound: parent), isNull);
});
});
});

group('getActiveElement returns the correct value when the active element is', () {
test('a valid element other than document.body', () async {
var activeElement = new DivElement()..tabIndex = 1;
document.body.children.add(activeElement);

await triggerFocus(activeElement);

expect(getActiveElement(), activeElement);
activeElement.remove();
});

test('document.body', () {
document.body.focus();

expect(getActiveElement(), isNull);
});
});
}

@Factory()
Expand Down
Loading

0 comments on commit 54b02b9

Please sign in to comment.