Skip to content

Commit

Permalink
Remove deprecated methods from 3.0 (#7333)
Browse files Browse the repository at this point in the history
Removes or hides remaining API that has been made deprecated in 1.0-2.2.
Only exclusion is @VaadinServletConfiguration, which is kept.

Fixes #6510
  • Loading branch information
pleku authored and Denis committed Jan 15, 2020
1 parent b735ebb commit e2b1141
Show file tree
Hide file tree
Showing 61 changed files with 217 additions and 1,271 deletions.
20 changes: 9 additions & 11 deletions flow-client/src/main/java/com/vaadin/client/BrowserInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public class BrowserInfo {
private static final String OS_LINUX = "lin";
private static final String OS_MACOSX = "mac";
private static final String OS_ANDROID = "android";
private static final String OS_IOS = "ios";

// Common CSS class for all touch devices
private static final String UI_TOUCH = "touch";
Expand Down Expand Up @@ -138,7 +137,7 @@ public boolean isSafari() {
* @return true if the browser is Safari or running on IOS, false otherwise
*/
public boolean isSafariOrIOS() {
return browserDetails.isSafariOrIOS();
return isSafari() || isIos();
}

/**
Expand Down Expand Up @@ -210,6 +209,14 @@ private static native String getBrowserString()
return $wnd.navigator.userAgent;
}-*/;



private static native boolean isIos()
/*-{
return (/iPad|iPhone|iPod/.test(navigator.platform) ||
(navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1));
}-*/;

/**
* Checks if the browser runs on a touch capable device.
*
Expand All @@ -219,15 +226,6 @@ public boolean isTouchDevice() {
return touchDevice;
}

/**
* Checks if the browser is run on iOS.
*
* @return true if the browser is run on iOS, false otherwise
*/
public boolean isIOS() {
return browserDetails.isIOS();
}

/**
* Checks if the browser is run on Android.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,10 +388,6 @@ String getFeatureDebugName(int id) {
nodeFeatureDebugName.set(NodeFeatures.CLASS_LIST, "classList");
nodeFeatureDebugName.set(NodeFeatures.ELEMENT_STYLE_PROPERTIES,
"elementStyleProperties");
nodeFeatureDebugName.set(NodeFeatures.SYNCHRONIZED_PROPERTIES,
"synchronizedProperties");
nodeFeatureDebugName.set(NodeFeatures.SYNCHRONIZED_PROPERTY_EVENTS,
"synchronizedPropertyEvents");
nodeFeatureDebugName.set(NodeFeatures.COMPONENT_MAPPING,
"componentMapping");
nodeFeatureDebugName.set(NodeFeatures.TEMPLATE_MODELLIST,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@
import java.util.function.Consumer;
import java.util.function.Supplier;

import jsinterop.annotations.JsFunction;

import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.Scheduler;

import com.vaadin.client.Command;
import com.vaadin.client.Console;
import com.vaadin.client.ExistingElementMap;
Expand Down Expand Up @@ -53,6 +48,10 @@
import com.vaadin.flow.internal.nodefeature.NodeFeatures;
import com.vaadin.flow.internal.nodefeature.NodeProperties;
import com.vaadin.flow.shared.JsonConstants;
import jsinterop.annotations.JsFunction;

import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.Scheduler;

import elemental.client.Browser;
import elemental.css.CSSStyleDeclaration;
Expand Down Expand Up @@ -135,9 +134,6 @@ private static class BindingContext {
private final JsMap<String, EventRemover> listenerRemovers = JsCollections
.map();

private final JsSet<EventRemover> synchronizedPropertyEventListeners = JsCollections
.set();

private BindingContext(StateNode node, Node htmlNode,
BinderContext binderContext) {
this.node = node;
Expand Down Expand Up @@ -217,7 +213,6 @@ assert hasSameTag(stateNode, htmlNode) : "Element tag name is '"

// Flow's own event listeners
listeners.push(bindDomEventListeners(context));
listeners.push(bindSynchronizedPropertyEvents(context));

// Dom structure, shouldn't trigger observers synchronously
listeners.push(bindVirtualChildren(context));
Expand Down Expand Up @@ -733,61 +728,6 @@ private void updateAttribute(MapProperty mapProperty, Element element) {
WidgetUtil.updateAttribute(element, name, mapProperty.getValue());
}

private EventRemover bindSynchronizedPropertyEvents(
BindingContext context) {
synchronizeEventTypesChanged(context);

NodeList propertyEvents = context.node
.getList(NodeFeatures.SYNCHRONIZED_PROPERTY_EVENTS);
return propertyEvents
.addSpliceListener(e -> synchronizeEventTypesChanged(context));
}

private void synchronizeEventTypesChanged(BindingContext context) {
NodeList propertyEvents = context.node
.getList(NodeFeatures.SYNCHRONIZED_PROPERTY_EVENTS);

// Remove all old listeners and add new ones
context.synchronizedPropertyEventListeners
.forEach(EventRemover::remove);
context.synchronizedPropertyEventListeners.clear();

for (int i = 0; i < propertyEvents.length(); i++) {
String eventType = propertyEvents.get(i).toString();
EventRemover remover = context.htmlNode.addEventListener(eventType,
event -> handlePropertySyncDomEvent(context), false);
context.synchronizedPropertyEventListeners.add(remover);
}
}

private void handlePropertySyncDomEvent(BindingContext context) {
NodeList propertiesList = context.node
.getList(NodeFeatures.SYNCHRONIZED_PROPERTIES);
for (int i = 0; i < propertiesList.length(); i++) {
syncPropertyIfNeeded(propertiesList.get(i).toString(), context);
}
}

/**
* Synchronizes the given property if the value in the DOM does not match
* the value in the StateTree.
* <p>
* Updates the StateTree with the new property value as a side effect.
*
* @param propertyName
* the name of the property
* @param context
* operation context
*/
private void syncPropertyIfNeeded(String propertyName,
BindingContext context) {
Object currentValue = WidgetUtil.getJsProperty(context.htmlNode,
propertyName);

context.node.getMap(NodeFeatures.ELEMENT_PROPERTIES)
.getProperty(propertyName).syncToServer(currentValue);
}

private EventRemover bindChildren(BindingContext context) {
NodeList children = context.node.getList(NodeFeatures.ELEMENT_CHILDREN);
if (children.hasBeenCleared()) {
Expand Down Expand Up @@ -1153,8 +1093,6 @@ private void remove(JsArray<EventRemover> listeners, BindingContext context,

context.listenerRemovers.forEach((remover, name) -> remover.remove());
listeners.forEach(EventRemover::remove);
context.synchronizedPropertyEventListeners
.forEach(EventRemover::remove);

assert boundNodes != null;
boundNodes.delete(context.node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1246,8 +1246,7 @@ public void testBindVirtualChild_withCorrespondingElementInShadowRoot_byTagNameA

List<Integer> expectedAfterBindingFeatures = Arrays.asList(
NodeFeatures.POLYMER_SERVER_EVENT_HANDLERS,
NodeFeatures.ELEMENT_CHILDREN,
NodeFeatures.SYNCHRONIZED_PROPERTY_EVENTS);
NodeFeatures.ELEMENT_CHILDREN);

expectedAfterBindingFeatures.forEach(notExpectedFeature -> assertFalse(
"Child node should not have any features from list "
Expand Down Expand Up @@ -1298,8 +1297,7 @@ public void testBindVirtualChild_withCorrespondingElementInShadowRoot_byId() {

List<Integer> expectedAfterBindingFeatures = Arrays.asList(
NodeFeatures.POLYMER_SERVER_EVENT_HANDLERS,
NodeFeatures.ELEMENT_CHILDREN,
NodeFeatures.SYNCHRONIZED_PROPERTY_EVENTS);
NodeFeatures.ELEMENT_CHILDREN);

expectedAfterBindingFeatures.forEach(notExpectedFeature -> assertFalse(
"Child node should not have any features from list "
Expand Down Expand Up @@ -1349,8 +1347,7 @@ public void testBindVirtualChild_withDeferredElementInShadowRoot_byId() {

List<Integer> expectedAfterBindingFeatures = Arrays.asList(
NodeFeatures.POLYMER_SERVER_EVENT_HANDLERS,
NodeFeatures.ELEMENT_CHILDREN,
NodeFeatures.SYNCHRONIZED_PROPERTY_EVENTS);
NodeFeatures.ELEMENT_CHILDREN);

Binder.bind(node, element);

Expand Down Expand Up @@ -1424,8 +1421,7 @@ public void testBindVirtualChild_withDeferredElementInShadowRoot_byIndicesPath()

List<Integer> expectedAfterBindingFeatures = Arrays.asList(
NodeFeatures.POLYMER_SERVER_EVENT_HANDLERS,
NodeFeatures.ELEMENT_CHILDREN,
NodeFeatures.SYNCHRONIZED_PROPERTY_EVENTS);
NodeFeatures.ELEMENT_CHILDREN);

Reactive.flush();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,22 +134,6 @@ public void testAddChildDoubleBind() {
Binder.bind(node, element);
}

public void testSynchronizedPropertyDoubleBind() {
NodeList synchronizedPropertyList = node
.getList(NodeFeatures.SYNCHRONIZED_PROPERTIES);
NodeList synchronizedPropertyEventsList = node
.getList(NodeFeatures.SYNCHRONIZED_PROPERTY_EVENTS);

Binder.bind(node, element);

synchronizedPropertyEventsList.add(0, "event");
synchronizedPropertyList.add(0, "tagName");
Reactive.flush();

node.setBound();
Binder.bind(node, element);
}

public void testDomEventHandlerDoubleBind() {
Binder.bind(node, element);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ public void clearSynchronizedProperties() {

protected NodeMap properties;
private NodeList synchronizedPropertyList;
private NodeList synchronizedPropertyEventsList;

@Override
protected void gwtSetUp() throws Exception {
Expand All @@ -149,114 +148,11 @@ protected void gwtSetUp() throws Exception {

node = createNode();
properties = node.getMap(NodeFeatures.ELEMENT_PROPERTIES);
synchronizedPropertyList = node
.getList(NodeFeatures.SYNCHRONIZED_PROPERTIES);
synchronizedPropertyEventsList = node
.getList(NodeFeatures.SYNCHRONIZED_PROPERTY_EVENTS);
synchronizedPropertyList = new NodeList(0, node);

element = Browser.getDocument().createElement("div");
}

public void testSynchronizePropertySendsToServer() {
// Must append for events to work in HTMLUnit
Browser.getDocument().getBody().appendChild(element);
Binder.bind(node, element);

setSyncEvents("event1");
setSyncProperties("offsetWidth", "tagName");
Reactive.flush();

assertSynchronized();
dispatchEvent("event1");
assertSynchronized("offsetWidth", "tagName");
}

public void testSynchronizePropertyOnlyOnChange() {
// Must append for events to work in HTMLUnit
Browser.getDocument().getBody().appendChild(element);
Binder.bind(node, element);

setSyncEvents("event");
setSyncProperties("offsetWidth", "offsetHeight");
Reactive.flush();

dispatchEvent("event");
assertSynchronized("offsetWidth", "offsetHeight");
tree.clearSynchronizedProperties();

dispatchEvent("event");
assertSynchronized();
tree.clearSynchronizedProperties();

element.getStyle().setWidth("123px");
dispatchEvent("event");
assertSynchronized("offsetWidth");
tree.clearSynchronizedProperties();

element.getStyle().setHeight("123px");
dispatchEvent("event");
assertSynchronized("offsetHeight");
}

public void testSynchronizePropertyAddRemoveEvent() {
// Must append for events to work in HTMLUnit
Browser.getDocument().getBody().appendChild(element);
Binder.bind(node, element);

setSyncEvents("event1", "event2");
setSyncProperties("offsetWidth");
Reactive.flush();

setSyncEvents("event2");
Reactive.flush();

dispatchEvent("event1");
assertSynchronized();
tree.clearSynchronizedProperties();
dispatchEvent("event2");
assertSynchronized("offsetWidth");
tree.clearSynchronizedProperties();

synchronizedPropertyEventsList.splice(0,
synchronizedPropertyEventsList.length());
dispatchEvent("event2");
assertSynchronized();

}

public void testSynchronizePropertyAddRemoveProperties() {
// Must append for events to work in HTMLUnit
Browser.getDocument().getBody().appendChild(element);
Binder.bind(node, element);

setSyncEvents("event1");
setSyncProperties("offsetWidth");
Reactive.flush();

element.getStyle().setHeight("1px");
element.getStyle().setWidth("1px");
dispatchEvent("event1");
assertSynchronized("offsetWidth");
tree.clearSynchronizedProperties();

setSyncProperties("offsetWidth", "offsetHeight");
Reactive.flush();

element.getStyle().setHeight("2px");
element.getStyle().setWidth("2px");
dispatchEvent("event1");
assertSynchronized("offsetWidth", "offsetHeight");
tree.clearSynchronizedProperties();

setSyncProperties();
Reactive.flush();
element.getStyle().setHeight("3px");
element.getStyle().setWidth("3px");
dispatchEvent("event1");
assertSynchronized();
tree.clearSynchronizedProperties();
}

public void testDomListenerSynchronization() {
// Must append for events to work in HTMLUnit
Browser.getDocument().getBody().appendChild(element);
Expand Down Expand Up @@ -294,14 +190,6 @@ protected StateNode createNode() {
return new StateNode(0, tree);
}

private void setSyncEvents(String... eventTypes) {
synchronizedPropertyEventsList.splice(0,
synchronizedPropertyEventsList.length());
for (int i = 0; i < eventTypes.length; i++) {
synchronizedPropertyEventsList.add(i, eventTypes[i]);
}
}

private void setSyncProperties(String... properties) {
synchronizedPropertyList.splice(0, synchronizedPropertyList.length());
for (int i = 0; i < properties.length; i++) {
Expand Down

0 comments on commit e2b1141

Please sign in to comment.