本文整理匯總了TypeScript中@ephox/sugar.Attr.get方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Attr.get方法的具體用法?TypeScript Attr.get怎麽用?TypeScript Attr.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@ephox/sugar.Attr
的用法示例。
在下文中一共展示了Attr.get方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
const fromLink = function (link) {
const text = TextContent.get(link);
const url = Attr.get(link, 'href');
const title = Attr.get(link, 'title');
const target = Attr.get(link, 'target');
return {
url: defaultToEmpty(url),
text: text !== url ? defaultToEmpty(text) : '',
title: defaultToEmpty(title),
target: defaultToEmpty(target),
link: Option.some(link)
};
};
示例2:
Logger.t('Check if iframe has the right custom attributes', Step.sync(function () {
const ifr = Element.fromDom(editor.iframeElement);
Assertions.assertEq('Id should not be the defined x', true, Attr.get(ifr, 'id') !== 'x');
Assertions.assertEq('Custom attribute whould have the right value', 'a', Attr.get(ifr, 'data-custom1'));
Assertions.assertEq('Custom attribute whould have the right value', 'b', Attr.get(ifr, 'data-custom2'));
}))
示例3:
const getAttr = (c, property: string): Option<any> => {
if (Attr.has(c, property)) {
return Option.some(Attr.get(c, property));
} else {
return Option.none();
}
};
示例4: function
const takeoverViewport = function (toolbarHeight, height, viewport) {
const oldViewportStyle = Attr.get(viewport, 'style');
Scrollable.register(viewport);
Css.setAll(viewport, {
position: 'absolute',
// I think there a class that does this overflow scrolling touch part
height: height + 'px',
width: '100%',
top: toolbarHeight + 'px'
});
Attr.set(viewport, yFixedData, toolbarHeight + 'px');
Attr.set(viewport, yScrollingData, 'true');
Attr.set(viewport, yFixedProperty, 'top');
const restore = function () {
Scrollable.deregister(viewport);
Attr.set(viewport, 'style', oldViewportStyle || '');
Attr.remove(viewport, yFixedData);
Attr.remove(viewport, yScrollingData);
Attr.remove(viewport, yFixedProperty);
};
return {
restore
};
};
示例5:
Step.sync(function () {
const component = memento.get(realm.socket());
Assertions.assertEq(
'Selected/Pressed state of component: (' + Attr.get(component.element(), 'class') + ')',
state,
Toggling.isOn(component)
);
}),
示例6:
const cGetDialogLabelId = Chain.binder((dialogE: Element) => {
if (Attr.has(dialogE, 'aria-labelledby')) {
const labelId = Attr.get(dialogE, 'aria-labelledby');
return labelId.length > 0 ? Result.value(labelId) : Result.error('Dialog has zero length aria-labelledby attribute');
} else {
return Result.error('Dialog has no aria-labelledby attribute');
}
});
示例7: function
Arr.each(clobberedEls, function (element) {
const restore = Attr.get(element, attr);
if (restore !== 'no-styles') {
Attr.set(element, 'style', restore);
} else {
Attr.remove(element, 'style');
}
Attr.remove(element, attr);
});
示例8: Error
Chain.op((dialog) => {
if (Attr.has(dialog, 'aria-labelledby')) {
const labelledby = Attr.get(dialog, 'aria-labelledby');
const dialogLabel = SelectorFind.descendant(dialog, '#' + labelledby).getOrDie('Could not find labelledby');
Assertions.assertEq('Checking label text', ariaLabel, Html.get(dialogLabel));
} else {
throw new Error('Dialog did not have an aria-labelledby');
}
})
示例9:
(editor: Editor, onSuccess, onFailure) => {
const replacedElem = Element.fromDom(editor.getElement());
Pipeline.async({ }, [
Chain.asStep(Body.body(), [
UiFinder.cFindIn(`#${Attr.get(replacedElem, 'id')}`),
Chain.binder((elem) => Traverse.nextSibling(elem).fold(() => Result.error('Replaced element has no next sibling'), Result.value)),
Chain.mapper((elem) => Class.has(elem, 'tox-tinymce')),
Assertions.cAssertEq('Replaced element\'s next sibling has "tox-tinymce" class', true)
])
], onSuccess, onFailure);
},